14.1 Introduction to Functions (15 mins)
function functionName(parameters) { // Code to be executed }function square(num) { return num * num; // Returns the square of the number }
functionName(arguments);let result = square(4); // Calls the function with 4 as an argument console.log(result); // Outputs: 16
function greet(name) { console.log("Hello, " + name); } greet("Alice"); // Outputs: Hello, Alice
function add(a, b) { return a + b; } let sum = add(5, 3); // sum is 8 console.log(sum); // Outputs: 8
Student Activity (15 mins):
Step-by-Step Activity:
Activity Follow-up Questions:
Expected Outcome:
Last updated