The "Note" about Generate Random


I am afraid I do not deep understand this note:

Note: Like Storing Values with the Assignment Operator, all function calls will be resolved before the return executes, so we can return the value of the Math.random() function.

I don’t understand what could be the probleme.
Could you please say me more about it ?

When you use the return keyword to exit the function and resolve to a value, it waits until all of the code to the right of it has resolved first.


// this
    let myRand = Math.random();
    return myRand;
// gives the exact same result as 
     return Math.random();

Ok, sorry but I think I have not enougth javascript knowledges to well understand where could be the problem.
For me it’s same situation as:

let myRand = a + b;

Is there other situations where right part of code is not resolve first ?

For both the assignment operator (=) and the return keyword, the code on the right will always resolve first.

Ok It was just for that.
I thought there was something more complicated.
I understood.
Thanks a lot :wink:

Happy coding!

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