From the course: JavaScript Essential Training
Unlock the full course today
Join today to access over 23,400 courses taught by industry experts.
Return values from a function - JavaScript Tutorial
From the course: JavaScript Essential Training
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
-
-
The real-world function2m 49s
-
(Locked)
Functions and methods6m 23s
-
(Locked)
A standard function3m 53s
-
(Locked)
The arrow function4m 49s
-
(Locked)
Arrow functions and "this"4m 20s
-
(Locked)
Practice: Build a function1m 31s
-
(Locked)
Pass data to a function with parameters4m 56s
-
(Locked)
Return values from a function7m 1s
-
(Locked)
Practice: Pass values between functions2m 33s
-
(Locked)
Callbacks5m 29s
-
(Locked)
Conditional if...else statement5m 52s
-
(Locked)
Logical operators3m 31s
-
(Locked)
Conditional switch statement5m 55s
-
(Locked)
Looping through content5m 19s
-
(Locked)
Using the map() array method4m 52s
-
(Locked)
Challenge intro: Create a content factory2m 36s
-
(Locked)
Solution: Create a content factory5m 21s
-
-
-
-