Goal: create a function
square(num)that returns the square of the given number.
* operatorMath.pow(num, 2) method**function square(num) {
return num * num;
}
window.square = square;Why this way:
num * num is simple, fast, and clear.Create a function square that takes a number and returns its square.
square(3); // 9
square(-4); // 16
square(1.5); // 2.25squareGoal: create a function
square(num)that returns the square of the given number.
* operatorMath.pow(num, 2) method**function square(num) {
return num * num;
}
window.square = square;Why this way:
num * num is simple, fast, and clear.Create a function square that takes a number and returns its square.
square(3); // 9
square(-4); // 16
square(1.5); // 2.25squareThe code editor is intentionally hidden on mobile.
Believe me, it's for the best: I am protecting you from the temptation to code in less-than-ideal conditions. A small screen and a virtual keyboard are not the best tools for a programmer.
📖 Now: Study the task, think through the solution. Act like a strategist.
💻 Later: Sit down at your computer, open the site, and implement all your ideas comfortably. Act like a code-jedi!