What does return do?


#1


What does return do in Javascript?


#2

I'm quoting from that particular lesson:

The return keyword simply gives the programmer back the value that comes out of the function. So the function runs, and when the return keyword is used, the function will immediately stop running and return the value.

So the return keyword is similar to console.log in that it "prints" out the value of the function. And when the function detects it, it will stop running and "print", or return the value.


Hope that helps!


#4

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