Skip to main content
← JavaScript

Programming Readiness Test

This test shows whether you are ready to move from JavaScript to Python. 46 marks, plus 3 bonus.

All the code here is JavaScript. You already know it. Read carefully and take your time.

Answer every question. Then click Check my answers. You can also check one question at a time as you go. At the end you get a score, a verdict, and a list of what to practise again.

Marks
46
Time
about 45 minutes
Paper version
Print or hand in

Section A: Quick Concepts

Choose the best answer. One mark each.

  1. A1.What does a variable do in a program?

    1 mark
  2. A2.After this code runs, what is the value of score?

    1 mark
    let score = 10;
    score = score + 5;
  3. A3.In JavaScript, which symbol CHECKS if two values are equal?

    1 mark
  4. A4.What is the position (index) of the FIRST item in an array?

    1 mark
  5. A5.True or False: a while loop always repeats an exact number of times that you choose in advance.

    1 mark
  6. A6.In Scratch, the "repeat 10" block is most like which JavaScript idea?

    1 mark
  7. A7.What does return do inside a function?

    1 mark
  8. A8.In JavaScript, what does "5" + 5 give you?

    1 mark

Section B: Trace the Code

Write exactly what each program prints, in order. Each console.log prints one line.

  1. B1.What does this print?

    2 marks
    let x = 4;
    let y = x * 2;
    x = x + 1;
    console.log(x);
    console.log(y);
  2. B2.What does this print?

    2 marks
    let age = 13;
    if (age >= 13) {
      console.log("teen");
    } else {
      console.log("kid");
    }
  3. B3.What does this print?

    3 marks
    let total = 0;
    for (let i = 1; i <= 4; i++) {
      total = total + i;
    }
    console.log(total);
  4. B4.What does this print?

    3 marks
    let count = 0;
    while (count < 3) {
      console.log("hi");
      count = count + 1;
    }
    console.log(count);
  5. B5.What does this print?

    3 marks
    let animals = ["cat", "dog", "bird"];
    console.log(animals[1]);
    console.log(animals.length);
  6. B6.What does this print?

    4 marks
    for (let i = 1; i <= 3; i++) {
      for (let j = 1; j <= 2; j++) {
        console.log(i + "-" + j);
      }
    }
  7. B7.What does this print?

    3 marks
    function double(n) {
      return n * 2;
    }
    let result = double(3) + double(5);
    console.log(result);

Section C: Spot the Bug

Each program has one bug. Say what is wrong. Then say how you would fix it. Three marks each.

  1. C1.This should print "Welcome!" only when the password is correct, but it prints it no matter what.

    3 marks
    let password = "cat";
    if (password = "dragon") {
      console.log("Welcome!");
    }
  2. C2.This game should end when you run out of lives. But it never stops.

    3 marks
    let lives = 3;
    while (lives > 0) {
      console.log("Playing...");
    }
  3. C3.This should print the last colour in the list. It prints undefined instead.

    3 marks
    let colors = ["red", "green", "blue"];
    console.log(colors[3]);

Section D: Write Some Code

Write JavaScript, or write clear steps in plain English. Small syntax slips are fine if the logic is right.

  1. D1.Write a loop that prints the numbers 1 to 10, one per line.

    4 marks
  2. D2.Write a function called greet that takes a name. It must return the text "Hello, NAME!". It must not print it. For example, greet("Sam") should return "Hello, Sam!".

    5 marks
  3. BONUS.Bonus. Write a function called isEven that takes a number. It returns true if the number is even. It returns false if the number is odd. Hint: n % 2 gives the remainder when n is divided by 2.

    3 marks

0 of 21 answered

Teacher's versionHow to use this test, and the full marking guide.

This page marks itself, so the answers are in it. Anyone who opens the browser tools can read them. That is fine for practice and for a student checking their own work. Keeping the answers here is what makes the feedback possible.

For a test you are really grading, use the paper version. It holds no answers. The student downloads a text file to hand in. This site is public, so it does not publish the marking guide. Keep your copy as a local file and grade from that.

The student marks the written questions against a checklist. That is on purpose. No program grades a paragraph fairly. To tick the boxes, the student has to read the model answer closely. That teaches more than a number would.