Module 1: Understanding Function Scope
This commit is contained in:
parent
bd562c63a2
commit
cfc610bf1a
12
app.js
12
app.js
@ -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);
|
|
Loading…
x
Reference in New Issue
Block a user