Solution Review: Compute the Square of a Number
This review provides a detailed analysis of the ways to compute the square of a number.
We'll cover the following...
Solution #1: Multiplying Number with Itself
Press + to interact
function findSquare(testVariable) {return testVariable * testVariable;}// Driver Codevar testVariable = 5;console.log(findSquare(testVariable));
Explanation
The solution to this problem is simple. We multiply the input variable with itself and return the result.
...
Access this course and 1400+ top-rated courses and projects.