Tag Archives: JavaScript Examples

JS Example for Beginners: JavaScript Program to Compare The Value of Two Dates

Hits: 13 (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 …

JS Example for Beginners: JavaScript Program to Count the Number of Vowels in a String

Hits: 298 (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 …

JS Example for Beginners: JavaScript Program to Convert the First Letter of a String in to Upper Case

Hits: 6 (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 …

JS Example for Beginners: JavaScript Program to Reverse a String

Hits: 44 (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 …

JS Example for Beginners: JavaScript Program to Convert Decimal to Binary

Hits: 49 (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; …

JS Example for Beginners: JavaScript Program to Find the Factors of a Number

Hits: 17 (JavaScript programming Example for Beginners) JavaScript Program to Find the Factors of a Number In this example, you will learn to write a JavaScript program that finds all the factors of an integer. To be the factors of a number, the factor number should exactly divide the number (with 0 remainder). For example, The factor …

JS Example for Beginners: JavaScript Program to Make a Simple Calculator

Hits: 28 (JavaScript programming Example for Beginners) JavaScript Program to Make a Simple Calculator In this example, you will learn to write a program to make a simple calculator in JavaScript. Example 1: Simple Calculator with if..else if…else // program for a simple calculator // take the operator input let operator = prompt(‘Enter operator ( …