Skip to main content

Programming

Write real code, complete snippets, and reason about what code does.

No recorded answers.

1. Write a JavaScript function isEven(n) that returns true when n is even and false otherwise. </> Code Question
    function isEven(n) {
      return n % 2 === 0;
    }

    The remainder of an even number divided by 2 is 0. This demo checks syntax patterns in the browser; in a real Code question, QuizMachine runs your code in a sandbox and can suggest a score with AI.

    2. Complete the loop so it visits every item exactly once. __ Fill in the Blanks
    for (let i = 0; i items.length; i) { console.log(items[i]); }

    Indexes run from 0 up to, but not including, items.length, and the counter grows by one each time.

    3. Which of these collections keep items in the order you add them? Select all that apply. ☑ Multiple Choice

    Arrays, lists, and queues keep insertion order; a hash set makes no ordering promise.

    4. What does this expression return? ◉ Single Choice (Radio)
    2 + 1 * 2

    Multiplication is evaluated before addition: 2 + (1 * 2) = 4.

    Result

    Get started for free