About 597,000 results
Open links in new tab
  1. What's the fastest way to square a number in JavaScript?

    return Math.pow(number,2); return number * number; Or some other method that I don't know about. I'm not looking for a golfed answer, but the answer that's likely to be shortest in the …

  2. How to Square a Number in JavaScript - Delft Stack

    Feb 2, 2024 · When you need to square a number in JavaScript, one of the methods at your disposal is the Math.pow() method. The Math.pow() method is a built-in JavaScript function …

  3. JavaScript - how to square a number in three easy ways

    May 23, 2021 · You can find the square root of a number easily by using the JavaScript Math.sqrt() method which accepts the square number as its argument and return the square …

  4. How to Square a Number in JavaScript — Complete Guide

    Oct 2, 2023 · We will be writing a general JavaScript program to square any number irrespective of it being positive or negative. Let’s start. The very first step would be writing the basic syntax …

  5. Create a javascript program to accept number and display square it

    Mar 30, 2024 · This program prompts the user to enter a number, calculates the square of that number using the squareNumber function, and then displays the result using alert ().

  6. JavaScript program to take a number as input and calculate the square ...

    Jun 29, 2018 · Following program shows how to take a number as input and calculate the square of that number. var result = input * input; console.log("Squre of " + input + " is: " + result);

  7. How to square a number in JavaScript - Altcademy Blog

    Jun 9, 2023 · To square a number, we can provide the number as both the base and the exponent. Here's an example: In this example, we first declare a variable number and assign it …

  8. How to Square a Number in JavaScript? - Letstacle

    Aug 3, 2021 · Let’s write a basic JavaScript program using the multiplication (*) operator. We can also square a number using pow () function. This is an in-built function provided in the Math …

  9. square a number in javascript - Code Snippets with explanation

    Aug 5, 2023 · Here’s the simple script to square a number in JavaScript. return num * num; console.log(squareNumber(5)); // Outputs: 25. In this code snippet, we created a function …

  10. How to Square a Number in JavaScript: 3 Quick Explained

    The best way to square a number in Javascript is to use the exponentiation operator (**). You can also square a number by using Javascript’s Math.pow () function or the multiplication (*) operator.

  11. Some results have been removed
Refresh