In the code exercise at Codecademy[1], it asks you to cube a variable and I can easily do that using:
// Accepts a number x as input and returns its square
function square(x) {
return x * x;
}
// Accepts a number x as input and returns its cube
function cube(x) {
return x * x * x;
}
cube(7);
My question is for the cube function, why do I get a NaN error when I use the following code instead:
function cube(x) {
return x * square;
}
[1] http://www.codecademy.com/courses/functions_in_javascript/0#!/exercise/1
NaN.