About 3,200 results
Open links in new tab
  1. How to find square of n with a for loop javascript

    Aug 24, 2021 · The square of a number can be visualized as the number of squares in a grid. 5x5, for example, is 5 wide by 5 tall: You can think of the nested loop in your code for (let i = 1; i <= …

  2. Javascript print square using for loop and conditional statement …

    Oct 13, 2017 · I'm using console.log to 'print' the square: var dimension = 10; var edge = '*'; var inside = ' '; var printLine; for (var i = 1; i <= dimension; i++) { if (i === 1 || i === dimension) { …

  3. JavaScript code that calculates the squares and cubes from 0 to 10

    Write a JavaScript that calculates the squares and cubes of the numbers from 0 to 10 and outputs HTML text that displays the resulting values in an HTML table format. Solution

  4. Square each number in an array in javascript - Stack Overflow

    May 26, 2014 · Here is how it can be done, using a simple method called .forEach. array[index] = element* element; Best way to Square each number in an array in javascript. var arr1 = []; …

  5. Program to print first 10 perfect squares - GeeksforGeeks

    Jan 9, 2024 · We know that the first 10 perfect squares will be square of 1, square of 2, square of 3... till square of 10. So, iterate from 1 to 10 and print squares of each number. Step-by-step …

  6. JavaScript Program: Calculate Squares of Numbers - CodePal

    Learn how to write a JavaScript program that calculates the squares of numbers from 1 to a given input number. Use a loop to iterate through the numbers and print each square.

  7. Javascript to generate squares of 1 to n numbers - Krazytech

    Mar 10, 2020 · This post contains the Javascript to generate squares of 1 to n numbers. This script accepts a number as the input and generates the squares of all ‘n’ numbers starting …

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

    May 23, 2021 · This article will show you the three easy ways to square a number using JavaScript. The three different ways you can square a number are as follows: Using the …

  9. JavaScript Square - Tpoint Tech

    Mar 17, 2025 · We have understood that we can square a number and square an array in JavaScript. There are various ways with the help of which we can square a number such as …

  10. Calculate squares and cubes of numbers in JavaScript

    var square = Math. pow (num, 2); var cube = Math . pow ( num , 3 ) ; document . write ( "Square of " + num + " is " + square + " and Cube of " + num + " is " + cube ) ;

Refresh