Return a Value from a Function with

Can someone can explain me better this, Return a Value from a Function with Return

Tell us what’s happening:
Describe your issue in detail here.

Your code so far


function timesFive(sas) {
return sas * 5;
}

var answer = timesFive(5) // I do not understand this part;

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36

Challenge: Return a Value from a Function with Return

Link to the challenge:

This function is declared here:

Inside a var.

You could later give:

console.log(answer);

To declare it

ok, so
timesFive is the function, it is called adding the parenthesis after it with an argument inside, so timesFive(5)
this mean that the function timesFive is called with a value of 5 for the parameter sas, that means that the line return sas * 5 would execute as return 5 * 5 (because sas takes the value of 5)
so, that, which evalue to 25 is the output of the function

so timesValue(5) is 25
and 25 is stored in the variable answer with =

2 Likes

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.