Javascript Assessment: Sample Questions | Bryq

Beginner

Intermediate

Advanced

These are three sample questions from Bryq’s JavaScript assessment, a coding test for hiring JavaScript developers, front-end developers and full-stack engineers. The full assessment covers three levels: beginner, intermediate and advanced, from core syntax and modern ES6+ features to closures, performance and asynchronous JavaScript. Questions test both JavaScript concepts and the ability to read code and predict its output, with four options and one correct answer each.

Beginner

Intermediate

Question

What does the following code print?

const arr = [1, 2]; arr.push(3); console.log(arr.length);

Select your answer

3

A TypeError, because arr is a constant

2

undefined

WHY IS THIS THE CORRECT ANSWER

const prevents a variable from being reassigned, but it doesn’t make the array itself immutable. push() modifies the existing array, so it now has three elements. Reassigning arr to a new array, on the other hand, would throw a TypeError.

Intermediate

Intermediate

Question

What does the following code print?

for (var i = 0; i < 3; i++) { setTimeout(() => console.log(i), 0); }

Select your answer

3 3 3

0 1 2

0 0 0

undefined undefined undefined

WHY IS THIS THE CORRECT ANSWER

var is function-scoped, so all three callbacks share the same i, and they only run after the loop has finished, when i is 3. Declaring the loop variable with let creates a new binding for each iteration, which would print 0 1 2.

Advanced

Intermediate

Question

In what order does the following code print its output?

console.log('A'); setTimeout(() => console.log('B'), 0); Promise.resolve().then(() => console.log('C')); console.log('D');

Select your answer

A D C B

A B C D

A D B C

A C D B

WHY IS THIS THE CORRECT ANSWER

Synchronous code runs first, printing A and then D. Promise callbacks go into the microtask queue, which is emptied before the next task runs. That’s why C prints before the setTimeout callback B, even with a 0 ms delay.

Ready to see Bryq in action?

Start hiring based on real data.

Ready to see Bryq in action?

Start hiring based on

real data.

Ready to see Bryq in action?

Start hiring based on real data.