JavaScript


To prevent mischief code, JavaScript here runs under a custom v8 extension.

Reading

gets() - reads a line from the standard input

Every gets() reads the next line from the program

  • Examples
const line = gets();
const number = +gets();

Printing

Instead of console.log, use print() everywhere.

print(message) - prints a new line on the standard output

  • Examples
print(5);
print(Math.sqrt(n));

Testing locally

To submit the code copy the entire code and paste it in the current task.

In the test variable, which is array, put your test cases. Each line is an element from the array.

To test your tasks locally put the following lines on top of your file:

const getGets = (arr) => {
    let index = 0;

    return () => {
        const toReturn = arr[index];
        index += 1;
        return toReturn;
    };
};
// this is the test
const test = [
  '5',
  '1 3',
  '123 -3',
  '4 -150',
];

const gets = this.gets || getGets(test);
const print = this.print || console.log;