Available in 1, 3, 6 and 12 Months Free Updates Plans
PDF: $15 $60

Test Engine: $20 $80

PDF + Engine: $25 $99

JavaScript-Developer-I Practice Test


Page 12 out of 45 Pages

A developer creates a simple webpage with an input field. When a user enters text in
the input field and clicks the button, the actual value of the field must be displayed in the
console.
Here is the HTML file content:
<input type =” text” value=”Hello” name =”input”>
<button type =”button” >Display </button>
The developer wrote the javascript code below:
Const button = document.querySelector(‘button’);
button.addEvenListener(‘click’, () => (
Const input = document.querySelector(‘input’);
console.log(input.getAttribute(‘value’));
When the user clicks the button, the output is always “Hello”.
What needs to be done make this code work as expected?


A.

Replace line 04 with console.log(input .value);


B.

Replace line 03 with const input = document.getElementByName(‘input’);


C.

Replace line 02 with button.addEventListener(“onclick”, function() {


D.

Replace line 02 with button.addCallback(“click”, function() {





A.
  

Replace line 04 with console.log(input .value);



Refer to following code block:
Let array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,];
Let output =0;
For (let num of array){
if (output >0){
Break;
}
if(num % 2 == 0){
Continue;
}
Output +=num;
What is the value of output after the code executes?


A.

16


B.

36


C.

11


D.

25





A.
  

16



A developer has a formatName function that takes two arguments, firstName and lastName
and returns a string. They want to schedule the
function to run once after five seconds.
What is the correct syntax to schedule this function?


A.

setTimeout (formatName(), 5000, "John", "BDoe");


B.

setTimeout (formatName('John', ‘'Doe'), 5000);


C.

setTimout(() => { formatName("John', 'Doe') }, 5000);


D.

setTimeout ('formatName', 5000, 'John", "Doe');





D.
  

setTimeout ('formatName', 5000, 'John", "Doe');



Which three browser specific APIs are available for developers to persist data between page loads ?
Choose 3 answers


A.

IIFEs


B.

indexedDB


C.

Global variables


D.

Cookies


E.

ocalStorage.





A.
  

IIFEs



B.
  

indexedDB



E.
  

ocalStorage.



Refer to the code below:
Let car1 = new Promise((_ , reject) =>
setTimeout(reject, 2000, “car 1 crashed in” =>
Let car2 =new Promise(resolve => setTimeout(resolve, 1500, “car 2 completed”)
Let car3 =new Promise(resolve => setTimeout(resolve, 3000, “car 3 completed”)
Promise.race(( car1, car2, car3))
.then (value => (
Let result = ‘$(value) the race.’;)}
.catch(arr => {
console.log(“Race is cancelled.”, err);
});
What is the value of result when Promise.race executes?


A.

Car 3 completes the race


B.

Car 2 completed the race.


C.

Car 1 crashed in the race.


D.

Race is cancelled.





B.
  

Car 2 completed the race.




Page 12 out of 45 Pages
Previous