Practice & Assessment
Test your understanding of JavaScript Foundations
Multiple Choice Questions
6What does the following code log? console.log(typeof null);
Which of the following statements about const is true?
What is the output of: console.log("5" + 1);
What does the nullish coalescing operator (??) do differently from logical OR (||)?
What is the result of: let x; console.log(x);
Which loop is best suited for iterating over the values in an array?
Coding Challenges
1Grade Classifier
Write a function gradeClassifier(score) that takes a numeric score (0–100) and returns the letter grade as a string: 'A' for 90–100, 'B' for 80–89, 'C' for 70–79, 'D' for 60–69, 'F' for below 60. Input: a single number. Output: a single uppercase letter string. Edge case: handle values outside 0–100 by returning 'Invalid'. Time estimate: 15 minutes.
Mini Project
CLI Number Guessing Game
Build a number guessing game in Node.js. The program generates a random integer between 1 and 100 using Math.random(). The player gets 7 attempts. After each guess, print 'Too high', 'Too low', or 'Correct!'. Track the number of attempts used. When the game ends (win or lose), display the secret number and attempts taken. Use let/const appropriately, a while loop for the game loop, if-else for comparisons, and at least one ternary operator. Accept input via readline or hard-code a test sequence. Demonstrate that you understand scope by keeping secret and attempts in the correct scope.
