The number 162th is a tough problem named 'Local Scope and Functions' in Freecodecamp.org.
Here is the problem that they given.
function myLocalScope() { 'use strict'; console.log(myVar); } myLocalScope(); // Run and check the console // myVar is not defined outside of myLocalScope console.log(myVar); // Now remove the console log line to pass the test
Here is the steps to find the solution and
its video.
Steps
- Type var myVar = 10; below 'use strict';
- Run the code by pressing ctrl+Enter or Clicking Run Button.
- Now Remove only the second console.log(myVar); See below.
- Again Run the code by pressing ctrl+Enter or Clicking Run Button. You are done.
function myLocalScope() { 'use strict'; var myVar = 10; console.log(myVar); } myLocalScope(); // Run and check the console // myVar is not defined outside of myLocalScope console.log(myVar); // Now remove the console log line to pass the test
function myLocalScope() { 'use strict'; var myVar = 10; console.log(myVar); } myLocalScope(); // Run and check the console // myVar is not defined outside of myLocalScope console.log(myVar); // Now remove the console log line to pass the test
function myLocalScope() { 'use strict'; var myVar = 10; console.log(myVar); } myLocalScope(); // Run and check the console // myVar is not defined outside of myLocalScope // Now remove the console log line to pass the test
The final view of the code will be :
function myLocalScope() { 'use strict'; var myVar = 10; console.log(myVar); } myLocalScope(); // Run and check the console // myVar is not defined outside of myLocalScope // Now remove the console log line to pass the test
If you have any doubts, comment below.
Support me by clicking Thumbs UP :

Subscribe my channel :

Can you find a way to hack TpT resources?
ReplyDelete