[SOLVED] Question: Block Scope, Instruction 5


In Block Scope (light.js), Instruction 5 reads the following:

  1. Beneath the function call, log the value of lightWaves to the console from outside the function.

You’ll notice that it logs a ReferenceError since the variable is tied to the block scope of the function!

My code is the following:

const visibleLightWaves = () => {
  let lightWaves = 'Moonlight'; 


I receive the following error in the output:


ReferenceError: lightWaves is not defined
    at Object.<anonymous> (/home/ccuser/workspace/javascript_101_Unit_3b/light.js:7:13)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.runMain (module.js:605:10)
    at run (bootstrap_node.js:427:7)
    at startup (bootstrap_node.js:151:9)
    at bootstrap_node.js:542:3

However, this is to be expected as Instruction 5 is looking for a ReferenceError.

Instead, I receive the following hint:

Did you add a console.log() statement beneath the function call?
Did you log the value of the 'lightWaves' variable to the console, outside the function block?

I don’t know how to proceed as I feel I have done what has been asked.


Is this the correct lesson?

4. Block Scope

Try a page refresh and see it you still get the same error message from the SCT.


That error message says beneath the function call, you’ve currently got it above


Sorry @ionatan, but I think you did not read my entire code block.

visibleLightWaves();  //<-- function call
console.log(lightWaves);  //<-- this code is BENEATH the function call


@mtf was correct. I refreshed the page including browser cache and ran the same code again for instruction 5, which now PASSED! It seems there was an error in the editor.


Derp. Something clearly went wrong for me there, yeah. Thanks.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.