Last time, we learned how functions can return values. Now let's practice combining everything—functions that take parameters AND return results to solve real-world problems.
Engagement Message
Ready to build some practical functions?
Let's create a function that calculates something useful. This function takes a price and tax rate, then returns the total cost:
Engagement Message
What makes this function reusable?
The returned value can be used immediately! We don't always need to store it in a variable first. Watch how we use the result directly inside a console.log()
:
Engagement Message
Both approaches work. Which feels more natural to you?
Functions become powerful when they can call other functions. We can use one function's output as another function's input, creating calculation chains.
Engagement Message
Can you follow the chain: what's the final result?
Type
Fill in The Blanks
Markdown With Blanks
Your turn now!
Complete this function that converts minutes to hours and returns the result:
