From cfc610bf1a3d8ca052532b3b992ae87396c54deb Mon Sep 17 00:00:00 2001 From: "jason.zhu" Date: Wed, 12 May 2021 11:39:16 +1000 Subject: [PATCH] Module 1: Understanding Function Scope --- app.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app.js b/app.js index 0d2a380..c1c82aa 100644 --- a/app.js +++ b/app.js @@ -1,5 +1,9 @@ -function sum(num1, num2) { - return num1 + num2; +function greeting() { + 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); -console.log(result); \ No newline at end of file +greeting(); \ No newline at end of file