Tell us what’s happening:
Describe your issue in detail here.
I had posted a question about what arr.push vs arr.shift meant but now i’m just wondering what “return” means? I’ve jumped into the true or false exercises and I noticed a significant number of lessons that ask for returns and that’s what’s confusing me.
**Your code so far**
function welcomeToBooleans() {
// Only change code below this line
return true; // Change this line
// Only change code above this line
}
**Your browser information:**
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.2 Safari/605.1.15
So a good place to start is with an understanding of functions, from a mathematical standpoint.
Math has functions, like those on a calculator. sin(x) is a calculator function, as is x^2 (can’t figure how to do squared on my phone, but that’s the x-squared function). When we type a number on a calculator and press a function, the displayed number changes, becoming that number run through that function.
That new number? That’s the “returned value” of that function. Press 9.2, then the squared operation, the returned value (or return) from that function is 84.64.
The same principle applies to functions in the programming sense - we take some data, feed it into a function, the function uses that data to provide us with something else, and returns that something else to us.
If we have a reverseString function, and we feed it a string, it will likely give us back (or return) that string in reverse order. Wherever that function is evaluated (or called), that’s where it’ll return that value.
If we don’t need it for some reason, we don’t need to receive that returned value… But every function returns a value, even if it’s returning undefined.
Not entirely accurate, as functions always return something. If we don’t specify what to return, the default return value of undefined will be sent back. There is a very valid reason for this behavior, but it’s part of a much deeper conversation.