Tag Archives: JavaScript Examples

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

(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 of 12 is 1, 2, 3, 4, 6, and 12. …

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

(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 ( either +, …

JS Example for Beginners: JavaScript Program to Display the Multiplication Table

(JavaScript programming Example for Beginners) JavaScript Program to Display the Multiplication Table In this example, you will learn to generate the multiplication table of a number in JavaScript. Example 1: Multiplication Table Up to 10 // program to generate a multiplication table // take input from the user let number = parseInt(prompt(‘Enter an integer: ‘)); …

JS Example for Beginners: JavaScript Program to Print all Prime Numbers in an Interval

(JavaScript programming Example for Beginners) JavaScript Program to Print all Prime Numbers in an Interval In this example, you will learn to write a JavaScript program to print all the prime numbers between two numbers entered by a user. A prime number is a positive integer that is only divisible by 1 and itself. For example, 2, 3, 5, 7, 11 are the …

JS Example for Beginners: JavaScript Program to Check Prime Number

(JavaScript programming Example for Beginners) JavaScript Program to Check Prime Number In this example, you will learn to write a JavaScript program to check if a number is a prime number or not. A prime number is a positive integer that is only divisible by 1 and itself. For example, 2, 3, 5, 7, 11 are the first few prime numbers. Example: Check …

JS Example for Beginners: JavaScript Program to Find the Largest Among Three Numbers

(JavaScript programming Example for Beginners) JavaScript Program to Find the Largest Among Three Numbers In this example, you will learn to find the largest among three numbers in JavaScript. You can find the largest among three numbers using the if…else statement. Example 1: Largest Number Among Three Numbers // program to find the largest among three numbers …

JS Example for Beginners: Javascript Program to Check if a Number is Odd or Even

(JavaScript programming Example for Beginners) Javascript Program to Check if a Number is Odd or Even In this example, you will learn to write a JavaScript program to check if the number is odd or even. Even numbers are those numbers that are exactly divisible by 2. The remainder operator % gives the remainder when used with a number. …

JS Example for Beginners: Javascript Program to Check if a number is Positive, Negative, or Zero

(JavaScript programming Example for Beginners) Javascript Program to Check if a number is Positive, Negative, or Zero In this example, you will learn to check whether the number entered by the user is positive, negative or zero.   You will be using the if…else if…else statement to write the program. Example 1: Check Number Type with if…else …

JS Example for Beginners: Javascript Program to Generate a Random Number

(JavaScript programming Example for Beginners) Javascript Program to Generate a Random Number In this example, you will learn to generate a random number in JavaScript.   In JavaScript, you can generate a random number with the Math.random() function. Math.random() returns a random floating-point number ranging from 0 to less than 1 (inclusive of 0 and exclusive of 1) Example 1: Generate a Random Number // …

JS Example for Beginners: Javascript Program to Convert Celsius to Fahrenheit

(JavaScript programming Example for Beginners) Javascript Program to Convert Celsius to Fahrenheit In this example, you will learn to convert Celsius value to Fahrenheit in JavaScript.   You can convert the celsius value to fahrenheit by using the formula: fahrenheit = celsius * 1.8 + 32 Example: Celsius to Fahrenheit // program to convert celsius …