Please enable JavaScript to use CodeHS

Want to receive Question of the Day updates? Subscribe Here

JavaScript Question of the Day April 2, 2025

  1. Incorrect Correct No Answer was selected Invalid Answer

    Consider the following program:

    let x = 0;
    
    function main() {
        bar();
        console.log(x)
    }
    
    function foo() {
      x++;
    }
    
    function bar() {
      foo();
      foo();
      foo();
    }
    
    main();
    JavaScript

    What is the output of the program?