Tutorials › JavaScript Tutorial › JavaScript Quiz

JavaScript Quiz

10 min read · Lesson 23 of 23

Well done for reaching the end of the JavaScript Tutorial! This quiz checks the key ideas from every module: the basics, control flow, functions, arrays and objects, the DOM and events, JSON, asynchronous code and errors.

Choose one answer for each question. If you get one wrong, revisit the lesson linked in the summary below and try again.

Before you start

A quick warm-up. Predict the output of this program before running it:

Example JAVASCRIPT
const scores = [45, 82, 67, 90];
const passed = scores.filter((s) => s >= 50);
const average = passed.reduce((sum, s) => sum + s, 0) / passed.length;

console.log(passed.length);
console.log(Math.round(average));
console.log(average >= 80 ? "Distinction" : "Credit");
Result
3
80
Credit
Try it Yourself »

Did you get it right? filter kept three scores (82, 67 and 90). Their total is 239, and 239 / 3 is about 79.67. Math.round shows that as 80, but the ternary compares the unrounded average, which is below 80 – so the result is "Credit", not "Distinction".

Note: Small details like this – rounding for display versus comparing the real value – cause many real-world bugs. Always know exactly which value you are testing.

The quiz

Quiz 15 questions
1. Which keyword declares a variable that cannot be reassigned?
2. What does typeof "42" return?
3. What is the result of "5" + 3 in JavaScript?
4. Which comparison is true?
5. Which of these values is falsy?
6. What does [10, 9, 100].sort() produce?
7. Which array method returns a new array containing only the items that pass a test?
8. What does the loop for (const x of ["a", "b"]) give you in x?
9. How do you read the town property of an object stored in the variable shop?
10. What must you use to create an instance of a class called Order?
11. Which method finds the first element matching a CSS selector?
12. Inside a submit handler, what stops the form from reloading the page?
13. What does JSON.parse do?
14. In what order are the letters printed by: setTimeout(() => console.log("A"), 0); console.log("B");
15. Which block always runs, whether or not an error was thrown?

How did you do?

ScoreWhat next
13–15Excellent! You are ready to build real projects. Try making a shopping cart or a to-do list app.
9–12Good work. Review the lessons for the questions you missed.
0–8Go back through the lessons one module at a time – especially Data Types, Booleans & Comparisons and Array Methods.

Where to go next

  • Build a small project that uses the DOM and Events: a tip calculator, a quiz app, or a KES-to-USD converter.
  • Learn fetch() to load real data from an API – it uses the same promises and async/await you met in Async JavaScript.
  • Keep the JavaScript Reference open while you code.
Sign in or create a free account to track progress, earn XP, badges and a certificate.