Getting max of numbers in Javascript.

Learn how to get the maximum of numbers. max function in the Math object can be used to find the maximum of multiple numbers and array. Math.max(1,2); //2 Math.max(1,2,3); //3 If any one of the argument passed cannot be converted to number then it returns NaN Math.max(‘1’, 0); //1 Math.max(‘one’, 1); // NaN Math.max(1, 2, …

Removing space in string in Javascript

Learn how to remove space in string. If you want to remove all the space in the string thenΒ , you can use replace method var name = “Javascript jeep “; name.replace(/s/g,”); // Javascriptjeep s –> spaceg –> replace globally We can also replace the space with ‘-‘ var name = “Javascript jeep “; name.replace(/s/g,’-‘); // …

Misunderstanding on parsing Boolean

Learn about how to parse boolean in Javascript. Creating a boolean value using Boolean constructor var b = new Boolean(); b is an object which have the value false in it. But the problem here is most of the beginner think as we can use directly in ifΒ , but it results to misunderstanding if(b) { …

How to convert 24 hours format to 12 hours in Javascript.

Convert the 24 hours format time to 12 hours formatted time. You can get the time byΒ , var dt = new Date(); var hours = dt.getHours(); // gives the value in 24 hours format var minutes = dt.getMinutes() ; var finalTime = “Time – ” + hours + “:” + minutes; finalTime // final time …

Design a site like this with WordPress.com
Get started