JavaScript Variables Quiz 1. What keyword lets you create a changeable variable? A) let B) const C) var D) static Correct answer: A (let). let makes a variable you can change. 2. Which keyword creates a variable that cannot change? A) let B) const C) var D) none Correct answer: B (const). const cannot be changed. 3. Which keyword is used in old JavaScript? A) var B) let C) const D) old Correct answer: A (var). var is the old keyword. 4. What value does var have before setting it? A) 0 B) undefined C) null D) empty Correct answer: B (undefined). var starts as undefined. 5. What happens if you use let before declaring it? A) It works B) It becomes zero C) It gives an error D) It resets Correct answer: C (error). let gives ReferenceError. 6. Which keyword stays inside a block? A) var B) let C) global D) none Correct answer: B (let). let is block scoped. 7. Which keyword ignores block scope? A) var B) let C) const D) none Correct answer: A (var). var ignores blocks. 8. Which keyword is best for fixed values? A) let B) const C) var D) none Correct answer: B (const). const is for fixed values. 9. Which variable can change? A) const B) let C) static D) none Correct answer: B (let). let can change. 10. Which variable must have a value when created? A) var B) let C) const D) none Correct answer: C (const). const requires a value. 11. Which keyword should be avoided? A) const B) let C) var D) none Correct answer: C (var). var is unsafe. 12. What happens if you redeclare let? A) It works B) It errors C) It resets D) It ignores Correct answer: B. let cannot be redeclared. 13. What happens if you assign without var/let/const? A) It stops B) It becomes global C) It warns D) It resets Correct answer: B. It creates a global variable. 14. Which variable shows undefined before setting? A) var B) let C) const D) none Correct answer: A (var). var logs undefined. 15. Which variables throw ReferenceError before setting? A) var B) let C) const D) let and const Correct answer: D. let and const do this. 16. Which becomes part of window object? A) let B) var C) const D) none Correct answer: B (var). var attaches to window. 17. Which is best for loop counters? A) var B) let C) const D) none Correct answer: B (let). let is safer. 18. Which keyword allows shadowing? A) var B) let C) const D) none Correct answer: B (let). let allows shadowing. 19. Which keyword was added in ES6? A) var B) let C) const D) none Correct answer: B (let). let was added in ES6. 20. Which variable is safest for beginners? A) var B) let C) const D) none Correct answer: C (const). const avoids mistakes. Submit