Module 1: Understanding Function Scope

This commit is contained in:
jason.zhu 2021-05-12 11:39:16 +10:00
parent bd562c63a2
commit cfc610bf1a

12
app.js
View File

@ -1,5 +1,9 @@
function sum(num1, num2) { function greeting() {
return num1 + num2; let message = 'Hello';
let sayHi = function hi() {
let message = 'Hi';
};
sayHi();
console.log(message); // Hello as 'Hi' is out of scope
} }
let result = sum(2,3); greeting();
console.log(result);