File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 1+ // Path: src/01-intro/05-scope.js
2+
3+ let movie = 'Lord of the Rings' ; // {1}
4+
5+ function starWarsFan ( ) {
6+ const movie = 'Star Wars' ; // {2}
7+ return movie ;
8+ }
9+
10+ function marvelFan ( ) {
11+ movie = 'The Avengers' ; // {3}
12+ return movie ;
13+ }
14+
15+ function blizzardFan ( ) {
16+ const isFan = true ;
17+ let phrase = 'Warcraft' ; // {4}
18+ console . log ( 'Before if: ' + phrase ) ;
19+ if ( isFan ) {
20+ let phrase = 'initial text' ; // {5}
21+ phrase = 'For the Horde!' ; // {6}
22+ console . log ( 'Inside if: ' + phrase ) ;
23+ }
24+ phrase = 'For the Alliance!' ; // {7}
25+ console . log ( 'After if: ' + phrase ) ;
26+ }
27+
28+ console . log ( movie ) ; // Lord of the Rings
29+ console . log ( starWarsFan ( ) ) ; // Star Wars
30+ console . log ( marvelFan ( ) ) ; // The Avengers
31+ console . log ( movie ) ; // The Avengers
32+ blizzardFan ( ) ; // Before if: Warcraft, Inside if: For the Horde!, After if: For the Alliance!
33+
34+ // to see the output of this file use the command: node src/01-intro/05-scope.js
You can’t perform that action at this time.
0 commit comments