From the course: JavaScript Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Return values from a function

Return values from a function - JavaScript Tutorial

From the course: JavaScript Essential Training

Start my 1-month free trial

Return values from a function

- [Narrator] The tip calculator function executes code and outputs it directly into the console. In some cases, this is what we want a function to do, just immediately output content. In other cases, we want a function to return some content to where the function was originally called so that we can process that content further. So in this movie, we'll look at how to do that using the return keyword. If we look at the output from the tip calculator function right now, you'll notice we're using the punctuation mark to delineate the decimals in the currency. This is correct for some currencies in some languages but not for all of them. We're also not showing the correct currency symbols here or rather we can pass it in but we don't really know what they are. So we're not getting the correct output here. I want to upgrade my function to output the correct currency, formatting and symbols for whatever currency we are…

Contents