JavaScript program to find the square root

Configurare noua (How To)

Situatie

In this example, you’ll learn to write a program to find the square root of a number in JavaScript.

Solutie

Pasi de urmat

// take the input from the user
const number = prompt(‘Enter the number: ‘);

const result = Math.sqrt(number);
console.log(`The square root of ${number} is ${result}`);

Output

Enter the number: 9
The square root of 9 is 3

Tip solutie

Permanent

Voteaza

(7 din 16 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?