Answer: Option B) They create block scope for variables
Solution:
Code blocks in JavaScript create a new scope for variables, known as block scope, which limits their accessibility to the block in which they are defined.
5.
Which of the following is true about code blocks in JavaScript?
Answer: Option B) They can contain variable declarations, statements, and functions
Solution:
Code blocks in JavaScript can contain a variety of statements, including variable declarations, control flow statements, and even function declarations.
6.
What happens to variables declared inside a code block after the block executes?
Answer: Option B) To limit variable scope and prevent naming conflicts
Solution:
Code blocks in JavaScript help in organizing code, managing variable scope, and preventing naming conflicts by limiting the visibility and accessibility of variables to specific blocks of code.
8.
How do code blocks contribute to code organization in JavaScript?