(JavaScript programming Example for Beginners) JavaScript Program to Insert Item in an Array In this example, you will learn to write a JavaScript program that will insert an item at a specific index into an array. Example 1: Add Item to Array using splice() // program to insert an item at a specific index into …
(JavaScript programming Example for Beginners) JavaScript Program to Compare The Value of Two Dates In this example, you will learn to write a JavaScript program that will compare the values of two dates. Example: Compare Value of Two Dates // program to compare value of two dates // create two dates let d1 = …
(JavaScript programming Example for Beginners) Javascript Program to Display Current Date In this example, you will learn to write a JavaScript program that will display the current date. Example : Display Current Date // program to display the date // get local machine date time let date = new Date(); // get the date …
(JavaScript programming Example for Beginners) JavaScript Program to Format the Date In this example, you will learn to write a JavaScript program that will format a date. Example 1: Format The Date // program to format the date // get current date let currentDate = new Date(); // get the day from the date let …
(JavaScript programming Example for Beginners) JavaScript Program to Check Leap Year In this example, you will learn to write a JavaScript program that will check if a year is leap year or not. A year is a leap year if the following conditions are satisfied: The year is multiple of 400. The year is multiple of 4 and …
(JavaScript programming Example for Beginners) JavaScript Program to Count the Number of Vowels in a String In this example, you will learn to write a JavaScript program that counts the number of vowels in a string. The five letters a, e, i, o and u are called vowels. All other alphabets except these 5 vowels are called consonants. Example 1: Count …
(JavaScript programming Example for Beginners) JavaScript Program to Convert the First Letter of a String in to Upper Case In this example, you will learn to write a JavaScript program that converts the first letter of a string into uppercase. Example 1: Convert First letter to Upper Case // program to convert first letter of …
(JavaScript programming Example for Beginners) JavaScript Program to Reverse a String In this tutorial, you will learn to write a JavaScript program that reverses a string. Example 1: Reverse a String using for loop // program to reverse a string function reverseString(str) { // empty string let newString = “”; for (let i = str.length …
(JavaScript programming Example for Beginners) JavaScript Program to Convert Decimal to Binary In this example, you will learn to write a JavaScript program that converts a decimal number to a binary number. Example 1: Convert Decimal to Binary // program to convert decimal to binary function convertToBinary(x) { let bin = 0; let rem, …
(JavaScript programming Example for Beginners) JavaScript Program to Guess a Random Number In this example, you will learn to write a JavaScript program where the user has to guess a number generated by a program. Example: Program to Guess a Number // program where the user has to guess a number generated by a program …