Game Lab Documentation

Math.sqrt()

Category:Math

There are some math calculations that require you to take the square root. Math.sqrt(x) does not change the value of x, rather it returns the the square root of x.

Examples

Square Root of 16

Calculates the square root of 16 and prints it on the console.

var t = Math.sqrt(16);
console.log(t);

Syntax

Math.sqrt(x);

Parameters

NameTypeRequired?Description
xNumber

A number to take the square root of

Returns

A number that is the square root of x

Found a bug in the documentation? Let us know at support@code.org.