+ 2

What does a return statement?

I have a hard time understanding what the return statement is for and why do we use it. I would really appreciate if someone explained it to me as if I were a very dumb 5 year old. Thank you!

16th Jun 2018, 11:13 PM
Cai
Cai - avatar
3 odpowiedzi
+ 2
think of it as performing a calculation with your calculator and asking for a result
16th Jun 2018, 11:23 PM
ghali lawal
ghali lawal - avatar
+ 1
ghali lawal so the return gives the result to the calculation? Do we only use the statement if we're calculating something?
20th Jun 2018, 4:21 AM
Cai
Cai - avatar
0
Think about it as giving an input to your function, doing something with that input value and then spitting it out as new value with return statement.
16th Jun 2018, 11:15 PM
damyco
damyco - avatar