NewsImproved Interactive Lessons

Coding quiz

JavaScript basics quiz

Eight snippets where JavaScript does something you might not expect. Predict each one, then see why.

  1. Question 1 of 8

    What does this log?

    console.log("5" + 3);
  2. Question 2 of 8

    What does this log?

    console.log("5" - 3);
  3. Question 3 of 8

    What does this log?

    console.log(0.1 + 0.2 === 0.3);
  4. Question 4 of 8

    What happens when this runs?

    const name = "Ana";
    name = "Ben";
  5. Question 5 of 8

    What does this log?

    const a = [10, 20, 30];
    console.log(a[a.length]);
  6. Question 6 of 8

    What do these two lines log?

    console.log(1 == "1");
    console.log(1 === "1");
  7. Question 7 of 8

    What does this log?

    let s = "";
    for (let i = 0; i < 3; i++) {
      s += i;
    }
    console.log(s);
  8. Question 8 of 8

    What does this log?

    console.log(typeof null);

Answer all 8 questions to see your score.

JavaScript basics

Learn JavaScript basics with your own tutor

It finds out what you already know, starts from there, and adapts to every answer. Your first 14 days are free, no card needed.