- Executors
-
Learn
Learn Python Runnable examples, NumPy, pandas, and more Learn AI / Machine LearningNeural networks, ML and LLMs from scratch Learn C & C++ Pointers, memory, STL, and modern C++ Learn C#C# basics, OOP, LINQ, async, and .NET exercises Learn MatplotlibLine, bar, scatter and pie charts with live visualizers Learn RustOwnership, traits, error handling, and threads Learn GoSlices, interfaces, goroutines, and channels Python Algorithms Search, sorting, recursion, and visualizers O(n) C & C++ Algorithms Compare algorithms implemented in C and C++ Coding for Kids Learn to code by playing!
- QuizzesNew
- ChallengesNew
- For TeachersNew
- Updates
- Buy me a coffee
JavaScript let, const & var Quiz
This JavaScript quiz checks the three ways to declare a variable. You will predict output involving block scope, reassignment and redeclaration, and see why modern code uses const and let instead of var.
Sample question
Question 1 of 10What does this print?
let x = 1;
{
let x = 2;
}
console.log(x);
Show the answer
B. 1 The inner let x is a new variable that only lives inside the braces. Outside the block, x is still the outer one, which holds 1.
What this quiz covers
- Block scope with
letandconst - Function scope with
var - Why
conststops reassignment but not changes to an object - Redeclaring a variable with
varvslet varvsletin aforloop
Questions people ask
Do I need an account?
No. Anyone can play. Sign in to keep your XP, streak, badges and history.
Can I retake it?
Yes. Your best score is kept, and the questions and answers are shuffled each time.