FAQ: Scope - Block Scope


This community-built FAQ covers the “Block Scope” exercise from the lesson “Scope”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Web Development

Introduction To JavaScript

FAQs on the exercise Block Scope

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!


Why is the piece of code // console.log(lightWaves); as the last task in this thread implies, only correct if we type it in as a comment?

My understanding was that we should log the value of lightWaves to the console from outside the function as a code, not a comment but entering it as a part of the code does not generate the correct result (the ‘checkmark’ - passing the last step).


What I found confusing here was the switch to " define a function logVisibleLightWaves() ." when the answer actually required a Variable starting with Const before declaring the variable. This was especially confusing when the 2nd question actually asked you to declare a variable using Const.

Maybe it is because this set is related to Scope and blocks but when told to define a function I would normally assume you are looking for a function and not a variable plus a function.


Scripts generally compile on the fly, save for the first run, the compile phase when declarations are hoisted. After that, lines are parsed and compiled during execution. Functions declared as constants are rather special. They get parsed and pre-compiled on their first call. That is, they never need to be parrsed a second time as they are held in memory in compiled form for the duration of the session.