JavaScript-Developer-I Exam Questions

Total 221 Questions

Last Updated Exam : 22-Nov-2024

Refer to the code below:
<html lang=”en”>
<table onclick=”console.log(Table log’);”>
<tr id=”row1”>
<td>Click me!</td>
</tr>
<table>
<script>
function printMessage(event) {
console.log(‘Row log’);
}
Let elem = document.getElementById(‘row1’);
elem.addEventListener(‘click’, printMessage, false);
</script>
</html>
Which code change should be made for the console to log only Row log when ‘Click me! ’
is
clicked?


A.

Add.event.stopPropagation(); to window.onLoad event handler.


B.

Add event.stopPropagation(); to printMessage function.


C.

Add event.removeEventListener(); to window.onLoad event handler.


D.

Add event.removeEventListener(); toprintMessage function.





B.
  

Add event.stopPropagation(); to printMessage function.



The developer wants to test this code:
Const toNumber =(strOrNum) => strOrNum;
Which two tests are most accurate for this code?
Choose 2 answers


A.

console.assert(toNumber(‘2’) === 2);


B.

console.assert(Number.isNaN(toNumber()));


C.

console.assert(toNumber(‘-3’) < 0);


D.

console.assert(toNumber () === NaN);





A.
  

console.assert(toNumber(‘2’) === 2);



C.
  

console.assert(toNumber(‘-3’) < 0);



Refer to code below:
Let productSKU = ‘8675309’ ;
A developer has a requirement to generate SKU numbers that are always 19 characters lon,
starting with ‘sku’, and padded with zeros.
Which statement assigns the values sku0000000008675309 ?


A.

productSKU = productSKU .padStart (19. ‘0’).padstart(‘sku’);


B.

productSKU = productSKU .padEnd (16. ‘0’).padstart(‘sku’);


C.

productSKU = productSKU .padEnd (16. ‘0’).padstart(19, ‘sku’);


D.

productSKU = productSKU .padStart (16. ‘0’).padstart(19, ‘sku’);





D.
  

productSKU = productSKU .padStart (16. ‘0’).padstart(19, ‘sku’);



A developer is debugging a web server that uses Node.js The server hits a runtimeerror
every third request to an important endpoint on the web server.
The developer added a break point to the start script, that is at index.js at he root of the
server’s source code. The developer wants to make use of chrome DevTools to debug.
Which command can be run to access DevTools and make sure the breakdown is hit ?


A.

node -i index.js


B.

Node --inspect-brk index.js


C.

Node inspect index.js


D.

Node --inspect index.js





D.
  

Node --inspect index.js



A developer uses a parsed JSON string to work with user information as in the block below:
01 const userInformation ={
02 “ id ” : “user-01”,
03 “email” : “user01@universalcontainers.demo”,
04 “age” : 25
Which two options access the email attribute in the object?
Choose 2 answers


A.

userInformation(“email”)


B.

userInformation.get(“email”)


C.

userInformation.email


D.

userInformation(email)





A.
  

userInformation(“email”)



C.
  

userInformation.email



Refer to the code below:
let o = {
get js() {
let city1 = String("st. Louis");
let city2 = String(" New York");
return {
firstCity: city1.toLowerCase(),
secondCity: city2.toLowerCase(),
}
}
}
What value can a developer expect when referencing o.js.secondCity?


A.

Undefined


B.

‘ new york ’


C.

‘ New York ’


D.

An error





B.
  

‘ new york ’



Refer to the code below:

What is the value of result when the code executes?


A.

10-10


B.

5-5


C.

10-5


D.

5-10





A.
  

10-10



A developer wants to iterate through an array of objects and count the objects and count
the objects whose property value, name, starts with the letter N.
Const arrObj = [{“name” : “Zach”} , {“name” : “Kate”},{“name” : “Alise”},{“name” :
“Bob”},{“name” :
“Natham”},{“name” : “nathaniel”}
Refer to the code snippet below:
01 arrObj.reduce(( acc, curr) => {
02 //missing line 02
02 //missing line 03
04 ). 0);
Which missing lines 02 and 03 return the correct count?


A.

Const sum = curr.startsWith(‘N’) ? 1: 0;
Return acc +sum


B.

Const sum = curr.name.startsWith(‘N’) ? 1: 0;
Return acc +sum


C.

Const sum = curr.startsWIth(‘N’) ? 1: 0;
Return curr+ sum


D.

Const sum = curr.name.startsWIth(‘N’) ? 1: 0;
Return curr+ sum





B.
  

Const sum = curr.name.startsWith(‘N’) ? 1: 0;
Return acc +sum



Given the JavaScript below:
01 function filterDOM (searchString) {
02 const parsedSearchString = searchString && searchString.toLowerCase() ;
03 document.quesrySelectorAll(‘ .account’ ) . forEach(account => (
04 const accountName = account.innerHTML.toLOwerCase();
05 account. Style.display = accountName.includes(parsedSearchString) ? /*Insert
code*/;
06 )};
07 }
Which code should replace the placeholder comment on line 05 to hide accounts that do
not match the search string?


A.

‘ name ’ : ‘ block ’


B.

‘ Block ’ : ‘ none ’


C.

‘ visible ’ : ‘ hidden ’


D.

‘ hidden ’ : ‘ visible ’





B.
  

‘ Block ’ : ‘ none ’



A developer wants to use a module named universalContainersLib and then call functions
from it.
How should a developer import every function from the module and then call the functions
foo and bar?


A.

import * from '/path/universalContainersLib.js';
universalContainersLib. foo ()7 universalContainersLib.bar ();


B.

import {foo,bar} from '/path/universalCcontainersLib.js';
foo(): bar()?


C.

import all from '/path/universalContainersLib.js';
universalContainersLib.foo(); universalContainersLib.bar ();


D.

import * as lib from '/path/universalContainersLib.js';
lib.foo(); lib. bar ();





D.
  

import * as lib from '/path/universalContainersLib.js';
lib.foo(); lib. bar ();




Page 12 out of 23 Pages
Previous