Coderslang JavaScript Test
by Kwiz
Qs
14
Difficulty
Mid
Plays
3
Record
n/a
Description

This set of JavaScript test questions were first published at https://learn.coderslang.com/

Question Preview
What’s going to be printed to the console?
let str = '1';
str = +!str;
console.log(typeof str);
Question Preview
What’s the correct way to create an array in JS?
Question Preview
What will the output be?
const x = '2' + 3 - true + '1';
console.log(x);
Question Preview
What will be logged to the console?
let e1, e2;
try {
  console.log(null.length);
} catch (e) {
  e1 = e;
}
try {
  console.log(undefined.length);
} catch (e) {
  e2 = e;
}

console.log(e1.message.split(' ')[0] === e2.message.split(' ')[0]);
Question Preview
What will be logged to the screen?
const obj = { id: 1, getId: () => this.id };

console.log(obj.getId());
Question Preview
What will the result be?
const args = [1,2,3];

const arrowFunction = (x, y) => {
  return arguments[2];
}
const regularFunction = function(x, y) {
 return arguments[2];
}

console.log(arrowFunction(...args) === regularFunction(...args));
Question Preview
What will be printed to the screen?
const array = ['this', 'is', 'an', 'array'];
if (typeof array === 'array') {
  console.log("ARRAY!");
} else {
  console.log("SOMETHING WEIRD...");
}
Question Preview
Which message will be printed first?
setTimeout(() => {
  console.log('timeout log');
}, 0);
console.log('plain log');
Question Preview
Will we catch an error in the catch block?
try {
  Promise.reject('an error occurred');
} catch (e) {
  console.log('the error was caught');
}
Question Preview
What will be logged to the console?
console.log(null === null);
console.log(undefined === undefined);
console.log(null + undefined === null + undefined);
Question Preview
What will be logged to the console?
const animals = ['Cow', 'Horse', 'Dog', 'Cat', 'Rabbit' ];

for (let i = 0; i < animals.length; i++) {
  const animals = ['Whale', 'Dolphin'];
  console.log(animals[i]);
}
Question Preview
What will the answer be?
const x = Math.min();
const y = 0;

console.log(x > y);
Question Preview
What will be printed to the console?
console.log(9999999999999999); // There are sixteen 9s inside the brackets
Question Preview
True or false
const x = 0.1;
const y = 0.2;

console.log(x + y === 0.3);