Free JS-Dev-101 Practice Test Questions and Answers (2026)
Last Update Check
Q: 1
A developer creates a simple webpage with an input field. When a user enters text and clicks the
button, the actual value must be displayed in the console:
HTML:
JavaScript:
01 const button = document.querySelector('button');
02 button.addEventListener('click', () => {
03 const input = document.querySelector('input');
04 console.log(input.getAttribute('value'));
05 });
When the user clicks the button, the output is always "Hello".
What needs to be done to make this code work as expected?
Options
Discussion
No comments yet. Be the first to comment.
Be respectful. No spam.
Q: 2
Given the JavaScript below:
01 function filterDOM(searchString){
02 const parsedSearchString = searchString && searchString.toLowerCase();
03 document.querySelectorAll('.account').forEach(account => {
04
const accountName = account.innerHTML.toLowerCase();
05
account.style.display = accountName.includes(parsedSearchString) ? /* Insert code here */
06 });
07 }
Which code should replace the placeholder comment on line 05 to hide accounts that do not match
the search string?
Options
Discussion
No comments yet. Be the first to comment.
Be respectful. No spam.
Q: 3
Given the following code:
01 counter = 0;
02 const logCounter = () => {
03 console.log(counter);
04 };
05 logCounter();
06 setTimeout(logCounter, 2100);
07 setInterval(() => {
08 counter++;
09 logCounter();
10 }, 1000);
What will be the first four numbers logged?
Options
Discussion
No comments yet. Be the first to comment.
Be respectful. No spam.
Q: 4
A developer creates a new web server that uses Node.js. It imports a server library that uses events
and callbacks for handling server functionality. The server library is imported with require and is
made available to the code by a variable named server. The developer wants to log any issues that
the server has while booting up.
Which code logs an error at boot time with an event?
Options
Discussion
No comments yet. Be the first to comment.
Be respectful. No spam.
Q: 5
Refer to the code below:
01 x = 3.14;
02
03 function myFunction() {
04 'use strict';
05 y = x;
06 }
07
08 z = x;
09 myFunction();
Considering the implications of 'use strict' on line 04, which three statements describe the execution
of the code?
Options
Discussion
No comments yet. Be the first to comment.
Be respectful. No spam.
Q: 6
A developer wants to use a module called DatePrettyPrint.
This module exports one default function called printDate().
How can the developer import and use printDate()?
Options
Discussion
No comments yet. Be the first to comment.
Be respectful. No spam.
Q: 7
A page loads 50+
elements, all ads.
Developer wants to quickly and temporarily remove them.
Options:
Options
Discussion
No comments yet. Be the first to comment.
Be respectful. No spam.
Q: 8
Refer to the code:
01 let car1 = new Promise((_, reject) =>
02 setTimeout(reject, 2000, "Car 1 crashed in"));
03 let car2 = new Promise(resolve =>
04 setTimeout(resolve, 1500, "Car 2 completed"));
05 let car3 = new Promise(resolve =>
06 setTimeout(resolve, 3000, "Car 3 completed"));
07
08 Promise.race([car1, car2, car3])
09 .then(value => {
10
let result = '$(value) the race.';
11 })
12 .catch(err => {
13
console.log("Race is cancelled.", err);
14 });
What is the value of result when Promise.race executes?
Options
Discussion
No comments yet. Be the first to comment.
Be respectful. No spam.
Q: 9
Refer to the code below:
01 let total = 10;
02 const interval = setInterval(() => {
03 total++;
04 clearInterval(interval);
05 total++;
06 }, 0);
07 total++;
08 console.log(total);
Considering that JavaScript is single-threaded, what is the output of line 08 after the code executes?
Options
Discussion
No comments yet. Be the first to comment.
Be respectful. No spam.
Q: 10
Given the following code:
01 let x = null;
02 console.log(typeof x);
What is the output of line 02?
Options
Discussion
No comments yet. Be the first to comment.
Be respectful. No spam.
Q: 11
Code:
01 let array = [1, 2, 3, 4, 4, 5, 4, 4];
02 for (let i = 0; i < array.length; i++) {
03 if (array[i] === 4) {
04
array.splice(i, 1);
05
i--;
06 }
07 }
What is the value of array after execution?
Options
Discussion
No comments yet. Be the first to comment.
Be respectful. No spam.
Q: 12
A developer is asked to fix some bugs reported by users. To do that, the developer adds a breakpoint
for debugging.
01 function Car(maxSpeed, color) {
02 this.maxSpeed = maxSpeed;
03 this.color = color;
04 }
05 let carSpeed = document.getElementById('carSpeed');
06 debugger;
07 let fourWheels = new Car(carSpeed.value, 'red');
When the code execution stops at the breakpoint on line 06, which two types of information are
available in the browser console?
Options
Discussion
No comments yet. Be the first to comment.
Be respectful. No spam.
Q: 13
Original code:
01 let requestPromise = client.getRequest;
03 requestPromise().then((response) => {
04 handleResponse(response);
05 });
The developer wants to gracefully handle errors from a Promise-based GET request.
Which code modification is correct?
Options
Discussion
No comments yet. Be the first to comment.
Be respectful. No spam.
Q: 14
Code:
01 const sayHello = (name) => {
02 console.log('Hello ', name);
03 };
04
05 const world = () => {
06 return 'World';
07 };
08
09 sayHello(world);
This does not print "Hello World".
What change is needed?
Options
Discussion
No comments yet. Be the first to comment.
Be respectful. No spam.
Q: 15
Which two implementations of utils.js support foo and bar?
Options
Discussion
No comments yet. Be the first to comment.
Be respectful. No spam.
Q: 16
Refer to the code below:
01 let timedFunction = () => {
02 console.log('Timer called.');
03 };
04
05 let timerId = setInterval(timedFunction, 1000);
Which statement allows a developer to cancel the scheduled timed function?
Options
Discussion
No comments yet. Be the first to comment.
Be respectful. No spam.
Q: 17
A Node.js server library uses events and callbacks. The developer wants to log any issues the server
has at boot time.
Which code logs an error with an event?
Options
Discussion
No comments yet. Be the first to comment.
Be respectful. No spam.
Q: 18
Which option is true about the strict mode in imported modules?
Options
Discussion
No comments yet. Be the first to comment.
Be respectful. No spam.
Q: 19
A developer is creating a simple webpage with a button. When a user clicks this button for the first
time, a message is displayed.
The developer wrote the JavaScript code below, but something is missing. The message gets
displayed every time a user clicks the button, instead of just the first time.
01 function listen(event) {
02
03 alert('Hey! I am John Doe');
04
05 }
06 button.addEventListener('click', listen);
Which two code lines make this code work as required?
Options
Discussion
No comments yet. Be the first to comment.
Be respectful. No spam.
Q: 20
Refer to the code:
const pi = 3.1415926;
What is the data type of pi?
Options
Discussion
No comments yet. Be the first to comment.
Be respectful. No spam.
Question 1 of 20