Your new timesFive function always returns 25. But what they want is for you to make it take in an argument or parameter which can be any number and then multiply it by 5.
Look back at the challenge explanation tolearn how to do that. Or just lookcarefully at the function above called minusSeven
That function doesn’t have variables in the body, only hardcoded numbers, so it will always returns the same thing. Also, return stop the function from running, everything after that is not considered.
It’s the difference between
function returnOne(num) {
return 1;
}
returnOne(1); // returns 1
returnOne(25); // but also this returns 1
And this one
function returnNumber(num) {
return num;
}
returnNumber(1); // this returns 1
returnNumber(25); // this returns 25
The second one uses variables to determinate what to return
Create a function timesFive that accepts one argument, multiplies it by 5 , and returns the new value. See the last line in the editor for an example of how you can test your timesFive function.
Create a function that takes a value and returns it multiplied by five. If you don’t use a variable it will always return the same number
I would suggest going back to the challenge, looking at the example and resetting the code. Be sure that you’re NOT hard coding the function, make sure your console.log is accurate. You’ll get it.
You are calling the function from inside the function (don’t do that right now, you will learn about recursive functions later), you are not returning a number, and you are not using the parameter of the function to make the function return a different number everytime it is called with a different argument passed in
Look carefully at the example function, and read again the challenge description and requirements.
function functionName( /* here function parameters, if more than one they need to be separated by commas */ ) {
/* here function body, it should return something and use function parameter(s) */
}
// now let's call the function
functionName( /* here function arguments, for now make sure that they are the same number as parameters */ );
You can wrap the function call inside console.log() if you want to print what the function returns to the console
// Example
function minusSeven(num) {
return num - 7;
}
// Only change code below this line
function timesFive(number) {
return number * 5;
}
var ans = timesFive(5);
ans = timesFive(2);
ans = timesFive(0);
console.log(timesFive(5));
console.log(timesFive(2));
console.log(timesFive(0));
console.log(minusSeven(10));