// program to check an Armstrong number of n digits// take an inputconstnumber = prompt("Enter a positive integer");constnumberOfDigits = number.length;letsum =0;// create a temporary variablelettemp = number;while(temp >0) {letremainder = temp %10; sum += remainder ** numberOfDigit...
// program to check if a number is prime or not // take input from the user const number = parseInt(prompt("Enter a positive number: ")); let isPrime = true; // check if number is equal to 1 if (number === 1) { console.log("1 is neither prime nor composite number."); }...
We are required to write a JavaScript function that takes in two numbers, say, a and b and returns the total number of prime numbers between a and b (including a and b, if they are prime). For example − If a = 2, and b = 21, the prime numbers between them are 2, 3, 5,...
JavaScript exercises, practice and solution: Write a JavaScript program which iterates the integers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples o
Check number is Armstrong or not Check whether a Number is Prime or Not Find largest of three numbers Check number is palindrome or not Form validation Design calculator Disable right click on webpage Make the font bold Return multiple elements from function Get URL parameters? Copy text to cli...
Example 1: Find HCF using for Loop // program to find the HCF or GCD of two integerslethcf;// take inputconstnumber1 =parseInt(prompt('Enter a first positive integer: '));constnumber2 =parseInt(prompt('Enter a second positive integer: '));// looping from 1 to number1 and number2fo...
// program to convert decimal to binary // take input const number = parseInt(prompt('Enter a decimal number: ')); // convert to binary const result = number.toString(2); console.log('Binary:' + ' ' + result); Run Code Output Enter a decimal number: 9 Binary: 1001 In the abov...
// program to check if the number is even or odd // take input from the user const number = prompt("Enter a number: "); //check if the number is even if(number % 2 == 0) { console.log("The number is even."); } // if the number is odd else { console.log("The number...
paularmstrong/normalizr - Normalizes nested JSON according to a schema jsdom/jsdom - A JavaScript implementation of various web standards, for use with Node.js avajs/ava - Node.js test runner that lets you develop with confidence 🚀 node-red/node-red - Low-code programming for event-drive...
paularmstrong/normalizr - Normalizes nested JSON according to a schema fabricjs/fabric.js - Javascript Canvas Library, SVG-to-Canvas (& canvas-to-SVG) Parser jlmakes/scrollreveal - Animate elements as they scroll into view. react-bootstrap/react-bootstrap - Bootstrap components built with React...