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.
Question 1 of 20 · Page 1 / 2