Function parameters
π Scenario: You are creating a simple calculator that adds two numbers. You will write a function that takes two numbers as inputs and returns their sum.
π― Goal: Build a function called addNumbers that takes two parameters and returns their sum. Then call the function with specific numbers and display the result.
π What You'll Learn
Create a function named
addNumbers with two parameters: num1 and num2Inside the function, return the sum of
num1 and num2Call the function with the numbers 5 and 7
Print the result using
console.logπ‘ Why This Matters
π Real World
Functions with parameters are used everywhere in programming to reuse code and perform tasks with different inputs.
πΌ Career
Understanding how to write and use functions with parameters is essential for any programming job, as it helps build clean and efficient code.
Progress0 / 4 steps