JS1 Updated Flashcards

1
Q

A developer initiates a server with the file server,js and adds dependencies in the source codes package,json that
are required to run the server.
Which command should the developer run to start the server locally?

A. start server,js
B. npm start server,js
C. npm start
D. node start

A

C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

After user acceptance testing, the developer is asked to change the webpage background based on user’s
location. This change was implemented and deployed for testing.
The tester reports that the background is not changing, however it works as required when viewing on the
developer’s computer.
Which two actions will help determine accurate results?

Choose 2 answers

A . The developer should inspect their browser refresh settings.
B . The tester should disable their browser cache.
C . The developer should rework the code.
D . The tester should clear their browser cache.

A

A, D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

A developer wants to use a module called DataPrettyPrint. This module exports one default function called
printDate ().
How can a developer import and use the printDate() function?

A. import DataPrettyPrint from ‘/path/DataPrettyPrint.js’/
DataPrettyPrint.printDate();

B. import printDate from ‘/path/DataPrettyPrint.js’/
printDate();

C. import printDate from ‘/path/DataPrettyPrint.js’/
DataPrettyPrint.printDate();

D. import DataPrettyPrint() from ‘/path/DataPrettyPrint.js’/
printDate();

A

B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

A developer has the function, shown below, that is called when a page loads.

function onLoad(){
console.log(‘Page has Loaded’);
}

Where can the developer see the log statement after loading the page in the browser?

A . On the browser JavaScript console
B . On the terminal console running the web server
C . In the browser performance tools log
D . On the webpage console log

A

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

A developer at Universal Containers is creating their new landing page based on HTML, CSS, and JavaScript.
To ensure that visitors have a good experience, a script named personalizeWebsiteContent needs to be executed
when the webpage is fully loaded (HTML content and all related files), in order to do some custom initializations.
Which implementation should be used to call Fe:s:-a;::eHec5;te::.-.ter.: based on the business requirement above?

A . Add a listener to the window object to handle the DOMContentLoaded event

B . Add a handler to the personalizeWebsiteContent script to handle the load event

C . Add a listener to the window object to handle the lead event

D . Add a handler to the personalizeWebsiteContent script to handle the DOMContentLoaded event

A

C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Given the following code:

01 lext x = null;
02 console.log(typeof x);

What is the output of line 02?
A . ‘null’
B . ‘x
C . ‘undefined’ 0
D . ‘object’

A

D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

A developer tries to retrieve all cookies, then sets a certain key value pair in the cookie. These statements are
used:

01 document.cookie;
02 documet.cookie = ‘key=John Smith’;

What is the behavior?

A . Cookies are read, but the key value is not set because the value is not URL encoded.
B . Cookies are not read because line 01 should be document, cookies, but the key value is set and all cookies are
wiped.
C . A Cookies are read and the key value is set, the remaining cookies are unaffected.
D . Cookies are read and the key value is set, and all cookies are wiped.

A

C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Given the JavaScript below:

01 function filterDOM(searchString){
02 const parsedSearchString = searchsting && searchsting.toLowerCase();
03 document.querySelectorAll(‘.account’).forEach(account => {
04 const accountName = account.innerHTML.toLowerCase();
05 account.style.display = accountName.include(parseSearchString) ? //InsertCodeHere//
06 });
07 }

Which code should replace the placeholder comment on line 06 to hide accounts that do not match the search
string?
A . ‘None’ : ‘block’
B . ‘Visible : ‘hidden’
C . ‘Hidden, visible
D . ‘Block’ : ‘none

A

D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Refer to the code below:

01 function execute() {
02 return new promise((resolve, reject) => reject());
03 }
04 let promise = execute();
05
06 promise
07 .then(() => console.log(‘Resolved1’))
08 .then(() => console.log(‘Resolved2’))
09 .then(() => console.log(‘Resolved3’))
10 .catch(() => console.log(‘rejected’))
11 .then(() => console.log(‘Resolved4’));

What is the result when the Promise in the execute function is rejected?
A . Resolved1 Resolved2 Resolved3 Resolved4
B . Rejected
C . Rejected Resolved
D . Rejected1 Rejected2 Rejected3 Rejected Rejected Rejected4

A

C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Refer to the code below:

const car = {
price:100,
getPrice:function(){

return this.price;

}
};
const customCar = Object.create(car);
customCar.price = 70;
delete customCar.price;const result = customCar.getPrice();

What is the value of result after the code executes?

A . 100
B . undefined
C . null
D . 70

A

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Refer to the following code:
class Vehicle{
constructor(plate){
this.plate = plate;
}
}
class Truck extends Vehicle{
constructor(plate, weight){
//Missing code
this.weight = weight;
}
displayWeight(){
console.log(The truck ${this.plate} has a weight of ${this.weight}lb.);
}
}let myTruck = new Truck(‘123Ab’,5000);
myTruck.displayWeight();
Which statement should be added to missing code for the code to display ‘The truck 123AB has a
weight of 5000lb.

A . super(plate)
B . super.plate = plate
C . Vehicle.plate = plate
D . this.plate = plate

A

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

A developer has two ways to write a function:
Option A:
function Monster(){
this.growl = ()=>{
console.log(‘Grr!’);
}
}
Option B:
function Monster(){};
Monster.prototype.growl = ()=>{
console.log(‘Grr!’);
}
After deciding on an option, the developer creates 1000 monster objects.
How many growl methods are created with Option A and Option B?

A . 1000 for Option A, 1 for Option B
B . 1 methods for both
C . 1000 for both
D . 1 for Option A, 1000 for Option B

A

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Refer to the code below
let inArray = [[1,2],[3,4,5]];
which two statements results in the array [1,2,3,4,5]?

choose 2 answer

A . [ ].concat(…inArray);
B . [ ].concat.apply(inArray,[ ]);
C . [ ].concat([…inArray])
D . [ ].concat.apply([ ],inArray);

A

A, D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

At Universal Containers, every team has its own way of copying JavaScript objects. The code snippet shows an
Implementation from one team:

01 function Person() {
02 this.firstName = ‘John’:
03 this.lastName = ‘Doe’;
04 this.name = () => {
05 console.log(‘Hello $(this.firstName) $(this.lastName)’))
07 }
08}
09 const john = new Person();
10 const dan = JSON.stringify(JSON.parse(john));
11 dan.firstName = ‘Dan’;
12 dan.name();

What is the output of the code execution?

A . Hello John Doe
B . Hello Dan
C . Hello Dan Doe
D . SyntaxError: Unexpected token in JSON

A

D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

A developer writes the code below to calculate the factorial of a given number
function sum(number){
return number * sum(number-1);
}
sum(3);

what is the result of executing the code.

A . 0
B . 6
C . Error
D . -Infinity

A

C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Given the code below:

const delay = async delay =>{
return new Promise((resolve,reject)=>{
console.log(1);
setTimeout(resolve,deleay);
});
};
const callDelay = async ()=>{
console.log(2);
const yup = await delay(1000);
console.log(3);
}
console.log(4);
callDelay();
console.log(5);

What is logged to the console?
A . 4 2 1 5 3
B . 4 2 1 5 6
C. 4 5 1 2 3
D. 4 5 2 3 1

A

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Refer to the code below:
let car1 = new Promise((_ ,reject)=> setTimeout(reject,2000,’Car1 crashed in’));
let car2 = new Promise(resolve => setTimeout(resolve,1500,’Car2 completed’));
let car3 = new Promise(resolve => setTimeout(resolve,3000,’Car3 completed’));
Promise.race([car1,car2,car3])
.then(value=>{
let result = ${value} the race.;
}).catch(err=>{
console.log(‘Race is cancelled.’,err);
});
What is the value of result when promise.race execues?

A. Car1 completed the race.
B. Car2 completed the race.
C. Car3 completed the race.
D Race is cancelled.

A

B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Given the following code:
let x = null;
console.log(typeof x);

What is the output?

A . ‘object’
B . ‘undefined’
C . ‘null’
D . ‘x’

A

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Refer to the code below:
01 document.body.addEventListner(‘click’,(event)=>{
02 if(//Answer Goes here//){
03 console.log(‘myElement clicked);
04 }
05 });

Which replacement for the conditional statement on line 02 allows a developer to correctly determine
that a specific element, myElement on the page had been clicked?
A. event.target.id ==’myElement’
B. event.target ==’myElemnt’
C. event
D. target.id == ‘myElement’

A

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Refer to the HTML below:

//<div id='main'>
//<ul>
//<li>Leo</li>
//<li>Tony</li>
//<li>Tiger</li>
//</ul>
//</div>

Which JavaScript statement results in changing ‘’ The Lion.’’?

A . document.querySelectorAll(‘$main $TONY’).innerHTML = ‘’’ The Lion
B . document.querySelector(‘$main li:second-child’).innerHTML = ‘’ The Lion ‘;
C . document.querySelector(‘$main li.Tony’).innerHTML = ‘’’ The Lion ‘;
D . document.querySelector(‘$main li:nth-child(2)’),innerHTML = ‘’ The Lion. ‘;

A

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Refer to the following code:

//<html lang=’en;>
//<body>
//<span onclick=’console.log(‘Span Message);”>
//<button> Send Message</button>
//</span>
//</body>
//


function displayMessage(ev){
ev.stopPropagation();
console.log(‘button message’);
}
const elem = document.getElementById(‘mybutton’);
elem.addEventListner(‘click’, displayMessage);

//</script>
//</html>

A . document.querySelectorAll(‘$main $TONY’).innerHTML = ‘’’ The Lion
B . document.querySelector(‘$main li:second-child’).innerHTML = ‘’ The Lion ‘;
C . document.querySelector(‘$main li.Tony’).innerHTML = ‘’’ The Lion ‘;
D . document.querySelector(‘$main li:nth-child(2)’),innerHTML = ‘’ The Lion. ‘;

A

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

Given the HTML below:

//<div>
//<div id='row-wc'>Univeral Containers</div>
//<div id='row-as'>Applied Shipping</div>
//<div id='row-bt'>Burlington Textiles</div>
//</div>

Which statement adds the priority-account css class to the Applied Shipping row?

A. document.querySelector(‘#row-as’).classList.add(‘priority-account’);
B. document.query (‘#row-as’).classList.add(‘priority-account’);
C. document.querySelector(‘#row-wc’).classList.add(‘priority-account’);
D. document.query (‘#row-bt’).classList.add(‘priority-account’);

A

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

Refer to the following code block:
class Animal{
constructor(name){
this.name = name;
}
makeSound(){
console.log(${this.name} is making a sound.)
}
}
class Dog extends Animal{
constructor(name){
super(name)
this.name = name;
}
makeSound(){
console.log(${this.name} is barking.)
}
}
let myDog = new Dog(‘Puppy’);
myDog.makeSound();

What is the console output?

A . Puppy is barking
B . Puppy is cracking
C. Puppy is making a sound
D. Undefined

A

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

A developer has an is Dog function that takes one argument cat. They want to schedule the function to run every
minute.

What is the correct syntax for scheduling this function?

A developer has an is Dog function that takes one argument cat. They want to schedule the function to run every
minute.
What is the correct syntax for scheduling this function?

A . setInterval(isDog, 60000,’cat’);
B . setInterval(isDog, 50000,’cat’);
C . setTimeout(isDog, 60000,’cat’);
D . setTimeout(isDog, 50000,’cat’);

A

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

Refer to the string below.

Const str=’Salesforce’;

Which two statements results in the word ‘Sales’?

Pick 2

A. Str.substring(0,5);
B. Str.substring(1,5);
C. Str.substr(0,5);
D. Str.substr(1,5);

A

A, C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

Refer the code below.

x=3.14;
function myfunction() {
‘use strict’;
y=x;
}
z=x;
myFunction();

Pick 3

A . Z is equal to 3.14
B. USe string affects the rest of the page
C. Use strict has effect only on line 5.
D. Line 5 throws an error
E. USe string affect line 3 and down

A

A, C, D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

Refer the following code

let array = [1,2,3,4,4,5,4,4]

for(let i=0 I<array.length; i++ ){
if(array[i]===4){
array.splice(i,1);
i–;
}
console.log(array);

what is the value of array after code executes?

A. [1,2,3,5]
B. [1,2,3,4]
C. [4,5,4,4]
D. [4,4,5,4]

A

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

Refer to the code:

function Animal (size, type) {

this.size = size || ‘small’;
this.type = type || ‘Animal’;
this.cantalk = false;
}

let pet = function (size, type, name, owner){
Animal.call(this, size, type);

this.name = name;
this.owner = owner;

pet prototype = object.create(Animal.prototype);
let pet1 = new Pet();

Given the code above, which three properties are set for pet1?

Choose 3 answers

A . name
B . owner
C . type
D . canTalk
E . size

A

C,D,E

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

A developer has an ErrorHandler module that contains multiple functions.
What kind of export should be leveraged so that multiple functions can be used?

A . all
B . named
C . multi
D . default

A

B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

Which code change should be done for the console to log the following when ‘Click me!’ is clicked’

> Row log
Table log

A . Remove lines 13 and 14
B . Change line 10 to event.stopPropagation (false) ;
C . Change line 14 to elem.addEventListener (‘click’, printMessage, true);
D . Remove line 10

A

B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

Refer to the following code:

01 fucntion Tiger() {
02 this.type = ‘Cat’;
03 this.size = ‘large’;
04 }
05
06 let Tony = new Tiger();
07 tony.roar = () => {
08 console.log(‘They're great!’);
09 );
10
11 function Lion() {
12 this.type = ‘Cat’;
13 this.size = ‘Large’;
14 }
15
16 let leo = new Lion();
17 // insert code here
18 leo.roar();

Which two statement could be inserted at line 17 to enable the function call on line 18?

Choose 2 answers

A . Object.assign (leo, tony);
B . Object.assign (leo. Tiger);
C . leo.roar = () => { console.log(‘They're pretty good!’); );
D . leo.prototype.roar = ( ) =>( console.log(‘They're pretty good!’); };

A

A,C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

Given the JavaScript below:

01 function filterDOM(searchString){
02 const parsedSearchString = searchsting && searchsting.toLowerCase();
03 document.querySelectorAll(‘.account’).forEach(account => {
04 const accountName = account.innerHTML.toLowerCase();
05 account.style.background = accountName.include(parseSearchString) ? //InsertCodeHere//
06 });
07 }

Which code should replace the placeholder comment on line 05 to highlight accounts that match the search
string’

A . ‘yellow’ : null
B . null : ‘yellow’
C . ‘none1 : ‘yellow’
D . ‘yellow : ‘none’

A

D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
33
Q

Refer to the string below:
const str = ‘Salesforce’;
Which two statements result in the word ‘Sales’?

Choose 2 answers

A . str.substr(1, 5);
B . str.substr (0, 5);
C . str.substring (1, 5);
D . str.substring (0, 5);

A

B,D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
34
Q

A developer is leading the creation of a new web server for their team that will fulfill API requests from an existing
client.
The team wants a web server that runs on Node.Js, and they want to use the new web framework Minimalist.Js.
The lead developer wants to advocate for a more seasoned back-end framework that already has a community
around it.

Which two frameworks could the lead developer advocate for?

Choose 2 answers

A . Gatsby
B . Angular
C . Express
D . Koa

A

B,C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
35
Q

Given the HTML below:

//<div>
// <div id ="row-uc">Univeral Containers</div>
// <div id ="row-as">Applied Shipping</div>
// <div id ="row-bt">Burlington Textiles</div>
//</div>

Which statement adds the priority-account CSS class to the Universal Containers row?

A . document.querySelector (#row-uc’).classes-push(‘priority-account’);
B . document.getElementByid(‘row-uc’).addClass(‘priority-account*);
C . document.querySelectorAll(‘#row-uc’) -classList.add(‘priority-accour’);
D . document.queryselector(‘#row-uc’).ClassList.add(‘priority-account’);

A

D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
36
Q

01 setTimeout (() => {
02 console.log(1);
03 ),1100);
04 console.log(2);
05 new Promise ((resolve, reject) => {
06 setTimeout (() => {
07 console.log(3);
08 },1000);
09}}.catch(() => {
10 console.log(4);
11 });
12 console.log(5);

What is logged to the console
A . 1 2 3 4 5
B . 1 2 5 3 4
C . 2 5 1 3 4
D . 2 5 3 4 1

A

D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
37
Q

Given the code below:
Which three code segments result in a correct conversion from number to string?

Choose 3 answers

A . let strValue = numValue. toString();
B . let strValue = * * 4 numValue;
C . let strValue = numValue.toText ();
D . let scrValue = String(numValue);
E . let strValue = (String)numValue;

A

A,B,D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
38
Q

Given the following code, what is the value of x?

let x = ‘15’ + (10 * 2);

A . 35
B . 50
C . 1520
D . 3020

A

C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
39
Q

A developer wants to create an object from a function in the browser using the code below.

01 function Monster(){ this.name = hello };
02 const = Monster();

What happens due to the lack of the mm keyword on line 02?

A . window.name is assigned to ‘hello’ and the variable = remains undefined.
B . window.m Is assigned the correct object.
C . The m variable is assigned the correct object but this.name remains undefined.
D . The m variable is assigned the correct object.

A

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
40
Q

A developer has the following array of hourly wages:

Let arr = (8, 5, 9, 75, 11, 25, 7, 75, , 13, 25);

For workers making less than $10 an hour rate should be multiple by 1.25 and returned in a new array.

How should the developer implement the request?

A . let arrl = arr.filter((val) => val < 10).map((num) -> num = 1.25);
B . let arrl = arr .rr.acArray ((val) => ( val < 10 )) ,map((num) => { num * 1.25 ));
C . let arrl = arr-map((num) => { return ran * 1.25 }).filter((val) -> { return val < 10));
D . let arrl = arr.filterBy((val) => val < 10 ).aapBy<(num) -> num = ..25 );

A

C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
41
Q

Refer to the code declarations below:

let str1 = ‘Java’;
let str2 = ‘Script’;

Which three expressions return the string JavaScript?

Choose 3 answers

A . Str1.join (str2);
B . Str1.concat (str2);
C . Concat (str1, str2);
D . $(str1) $ (str2} ‘;
E . Str1 + str2;

A

B,D,E

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
42
Q

Refer to the following code:

let obj = {
foo: 1,
bar: 2
}

let output = [];

for(let something of obj) {
output.push(somehting);
}

console.log(output);

A . [1, 2]
B . ['’foo’’, ‘‘bar’’]
C . ['’foo’‘:1, ‘‘bar’‘:2’’]
D . An error will occur due to the incorrect usage of the for…of statement on line 07.

A

D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
43
Q

Refer to the following array:
Let arr = [1, 2, 3, 4, 5];

Which three options result in x evaluating as [1, 2]?
Choose 3 answer

A . let x = arr. slice (2);
B . let x = arr. slice (0, 2);
C . let x arr.filter((a) => (return a <= 2 });
D . let x = arr.filter ((a) => 2 }) ;
E . let x =arr.splice(0, 2);

A

B,C,E

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
44
Q

Refer to the following code:

class Ship{
constructor(size) {
this.size = size;
}
}

class FinishingBoat extends ship {
constructor(size, capacity) {
// missing code
this.capacity = capacity;
}

displyaycapacity(){
console.log(‘This boat has a capacity of $(this.capacity) people);
}
}
let myBoat = new FinishingBoat (‘medium’ 10 );
myBoat.displayCapacity();

Which statement should be added to line 09 for the code to display ‘The boat has a capacity of 10 people?

A . super.size = size;
B . ship.size = size;
C . super (size);
D . this.size = size;

A

D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
45
Q

Refer to the code below:

const myFunction = arr => {
return arr.reduce((result, current) => {
return result + current;
}, 5);

What is the output of this function when called with an empty array?
A . Return 0
B . Return 5
C . Return NaN
D . Return Infinity

A

B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
46
Q

A developer at Universal Containers is creating their new landing page based on HTML, CSS, and JavaScript. The
website includes multiple external resources that are loaded when the page is opened.

To ensure that visitors have a good experience, a script named personalizeWebsiteContent needs to be executed
when the webpage Is loaded and there Is no need to wait for the resources to be available.

Which statement should be used to call personalizeWebsiteContent based on the above business requirement?

A . windows,addEventListener(‘load’, personalizeWebsiteContent);
B . windows,addEventListener(‘DOMContent Loaded ‘, personalizeWebsiteContent);
C . windows,addEventListener(‘onload’, personalizeWebsiteContent);
D . windows,addEventListener(‘onDOMCContentLoaded’, personalizeWebsiteContent);

A

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
47
Q

A developer is setting up a Node,js server and is creating a script at the root of the source code, index,js, that will
start the server when executed. The developer declares a variable that needs the folder location that the code
executes from.

Which global variable can be used in the script?

A . window.location
B . _filename
C . _dirname
D . this.path

A

B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
48
Q

A developer copied a JavaScript object:

function person(){
this.firstName = ‘John’;
this.LastName = ‘Doe’;

this.name = () => ‘${this.firstName},${this.LastName};
}

const john = new person();
const dan = object.assign(john);
dan.FirstName = ‘Dan;

How does the developer access dan’s forstName,lastName? Choose 2 answers

A . dan.name
B . dan.firstname ( ) + dan.lastName ( )
C . dan.firstName = dan.lastName
D . dan.name ( )

A

B, D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
49
Q

There is a new requirement for a developer to implement a currPrice method that will return the current price of
the item or sales..

01 let regItem = new item(scarf , 50);
02 let salesItem = new SalesItem(shirt, 80, .1);
03 Item.protoType.currPrice = function() { return this.price }
04 console.log(regItem.currPrice());
05 console.log(saleItem.currPrice());
06
07 Saleitem.protoType.currPrice = function() { return this.price = this.price * this. discount}
08 console.log(regItem.currPrice());
09 console.log(saleItem.currPrice());

What is the output when executing the code above
A . 50
Uncaught TypeError: saleItem,desrcription is not a function
50
80

B . 50
80
50
72

C . 50
80
72

D . 50
80
Uncaught Reference Error:this,discount is undefined
72

A

B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
50
Q

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?
A . 0012
B . 0112
C . 0122
D . 0123

A

B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
51
Q

Refer to the following object.

01 const dog = {
02 firstName: ‘Beau’,
03 lastName: ‘Boo’,
04 get fullName() {
05 return this.firstName + ‘ ‘ + this.LastName;
06 }
07 );

How can a developer access the fullName property for dog?
A . Dog.fullName
B . Dog.fullName ( )
C . Dog, get, fullName
D . Dog, function, fullName

A

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
52
Q

A developer needs to debug a Node.js web server because a runtime error keeps occurring at one of the
endpoints.

The developer wants to test the endpoint on a local machine and make the request against a local server to look
at the behavior. In the source code, the server, js file will start the server. the developer wants to debug the
Node.js server only using the terminal.

Which command can the developer use to open the CLI debugger in their current terminal window?

A . node -i server.js
B . node inspect server,js
C . node server,js inspect
D . node start inspect server,js

A

B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
53
Q

Given the expressions var1 and var2, what are two valid ways to return the concatenation of the two expressions
and ensure it is string?

Choose 2 answers

A . var1 + var2
B . var1.toString ( ) var2.toString ( )
C . String (var1) .concat (var2)
D . string.concat (var1 +var2)

A

B,D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
54
Q

bar, awesome is a popular JavaScript module. the versions publish to npm are:
1.2
1.3.1
1.3.5
1.4.0

Teams at Universal Containers use this module in a number of projects. A particular project has the package, json
definition below.

{
“name”: “UC Project Extra”;
“version”: “0.0.5”
“dependencies”: {
“bar.awesome”: “~1.3.0”
}
}

A developer runs this command: npm install.
Which version of bar .awesome is installed?
A . 1.3.1
B . 1.3.5
C . The command fails, because version 130 is not found
D . 1.4.0

A

B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
55
Q

A developer is trying to handle an error within a function.
Which code segment shows the correct approach to handle an error without propagating it elsewhere?

A. Try{ doSomeything(); }Catch (error){ return error; }
B. Try{ doSomeything(); }Catch (error){ return null; }
C. Try{ doSomeything(); }Catch (error){ Throw new error (Error Found); }
D. Try{ doSomeything(); }Catch (error){ ProcessError(error); }

A

D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
56
Q

Which two options are core Node.js modules?

Choose 2 answers

A . worker
B . isotream
C . exception
D . http

A

B, D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
57
Q

Refer to the code below:

function Person () {
this.firstName = ‘John’;
}

Person.protoType = {
job: x => ‘Developer’
};

const myFather = new Person();
const result = myFather.FirstName + ‘ ‘ + myFather.job();

What is the value of result after line 10 executes?

A . Error: myFather.job is not a function
B . John Developer
C . undefined Developer
D . John undefined

A

B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
58
Q

Refer to the code below:

let country = {
get capitol () {
let city = Number(“London”);

return {
cityString: city.toString(),
}
}
}

Which value can a developer expect when referencing country,capital,cityString?
A . ‘London’
B . undefined
C . An error
D . ‘NaN’

A

D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
59
Q

Given the code below:

function Person(name, email) {
this.name = name;
this.email = email;
}

const john = new Person (John, john@email.com’);
const jane = new Person (Jane, jane@email.com’);
const emily = new Person (Emily, emily@email.com’);

let userList = [john, jane, emily];

Which method can be used to provide a visual representation of the list of users and to allow sorting by the name
or email attribute?

A . console.group(usersList) ;
B . console.table(usersList) ;
C . console.info(usersList) ;
D . console.groupCol lapsed (usersList) ;

A

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
60
Q

Refer to the code below:

01 let total = 10;
02 const interval = setInterval (() => {
03 total ++;
04 clearInterval (interval);
05 total++;
0+ ),0);
07 total ++;
08 console.log(total);

Considering that JavaScript is single-threaded, what is the output of line 08 after the code executes?
A . 10
B . 11
C . 12
D . 13

A

B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
61
Q

Refer to the following code block:

class student {
constructor(name) {
this.name = name;
}

takeTest() {
console.log(‘$(this.name ) got 70% on test)
}
}

class BetterStudent extends Student {
constructor(name){
super(name);
this.name = ‘Better Student ‘ + name;
}

takeTest() {
console.log(‘$(this.name) got 100% on test);
}
}

let student = new BetterStudent(Jackie);

student.TakeTest();

What is the console output?
A . > Better student Jackie got 70% on test.
B . > Jackie got 70% on test.
C . > Uncaught Reference Error
D . > Better student Jackie got 100% on test.

A

D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
62
Q

Which statement can a developer apply to increment the browser’s navigation history without a page refresh?
Which statement can a developer apply to increment the browser’s navigation history without a page refresh?

A . window.history.pushState(newStateObject);
B . window.history.pushStare(newStateObject, ‘ ‘, null);
C . window.history.replaceState(newStateObject,’ ‘, null);
D . window.history.state.push(newStateObject);

A

C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
63
Q

Considering the implications of ‘use strict’ on line 04, which three statements describe the execution of the code?

Choose 3 answers

A . z is equal to 3.14.
B . ‘use strict’ is hoisted, so it has an effect on all lines.
C . ‘use strict’ has an effect only on line 05.
D . ‘use strict’ has an effect between line 04 and the end of the file.
E . Line 05 throws an error.

A

A,C,E

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
64
Q

Refer to the following code:

let obj = {
foo: 1,
bar: 2
}

let output = [];

for(let something in obj) {
output.push(somehting);
}

console.log(output);

A . [1,2]
B . [‘bar’, ‘foo’]
C . [‘foo:1’, ‘bar:2’]
D . [‘foo’, ‘bar’]

A

D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
65
Q

myArraym can have one level, two levels, or more levels.
Which statement flattens myArray when it can be arbitrarily nested?

A . myArray. reduce ((prev, curr) => prev.concat(curr) [ ]);
B . myArray. join (‘,’). split (‘,’);
C . [ ] .concat {. . .myArray) ;
D . myArray.flat(Infinity);

A

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
66
Q

A developer writes the code below to return a message to a user attempting to register a new username. If the
username is available, a variable named nag is declared and assigned a value on line 03.

function getAvailableabilityMessage (item) {
if (getAvailability(item)){
var msg = ‘Username available’;
}
return msg;

}

What is the value of msg when getAvailableabilityMessage
(‘‘newUserName’’) is executed and getAvailability
(‘‘newUserName’’) returns true?

A . ‘msg is not defined’
B . ‘newUserName’
C . ‘Username available’
D . undefined

A

C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
67
Q

Refer of the string below:
Const str = ‘salesforce’=;
Which two statement result in the word ‘Sale’?

Choose 2 answers

A . str, substring (0,5) ;
B . str, substr(0,5) ;
C . str, substring(1,5) ;
D . str, substr(1,5) ;

A

A,B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
68
Q

developer uses the code below to format a date.

const date = new date(2020, 05, 10);

const displayoptions = {
year: numeric
month: long
day: numeric

};

const formattedDate = date.toLocaleDateString(‘en’, dateDispalyOptions);

After executing, what is the value of formattedDate?
A . May 10, 2020
B . June 10, 2020
C . October 05, 2020
D . November 05, 2020

A

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
69
Q

Refer to the code below:

function changeValue(param){
param = 5;
}

let a = 10
let b = a

changeValue(b);

const result = a + ‘-‘ + b

What is the value of result when the code executes?
A . 10-10
B . 5-5
C . 10-5
D . 5-10

A

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
70
Q

A developer has a web server running with Node.js. The command to start the web server is node server.js. The
web server started having
latency issues. Instead of a one second turnaround for web requests, the developer now sees a five second
turnaround.

Which command can the web developer run to see what the module is doing during the latency period?

A . NODE_DEBUG=true node server.js
B . DEBUG=http, https node server.js
C . NODE_DEBUG=http,https node server.js
D . DEBUG=true node server.js

A

D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
71
Q

A developer wrote the following code to test a sum3 function that takes in an array of numbers and returns the
sum of the first three numbers in the array, and the test passes.
A different developer made changes to the behavior of sum3 to instead sum only the first two numbers present in
the array.

let res = sum3([1,4,1])
console.assert(res===6);

let res = sum3([1,5,0,5])
console.assert(res===6);

Which two results occur when running this test on the updated sum3 function?

Choose 2 answers

A . The line 05 assertion passes.
B . The line 02 assertion passes.
C . The line 02 assertion fails.
D . The line 05 assertion fails.

A

B,D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
72
Q

Universal Containers (UC) just launched a new landing page, but users complain that the website is slow. A developer found some functions any that might cause this problem. To verify this, the developer decides to execute everything and log the time each of these three suspicious functions consumes.

console.time(‘Performace);

maybeHavyFunction();
thisCouldTakeTooLong();
orMaybeThisOne();

console.endtime(‘Performace’)

Which function can the developer use to obtain the time spent by every one of the three functions?
A . console. timeLog ()
B . console.timeStamp ()
C . console.trace()
D . console.getTime ()

A

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
73
Q

A test has a dependency on database. query. During the test, the dependency is replaced with an object called
database with the method,
Calculator query, that returns an array. The developer does not need to verify how many times the method has
been called.
Which two test approaches describe the requirement?

Choose 2 answers

A . White box
B . Stubbing
C . Black box
D . Substitution

A

A,D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
74
Q

Given the following code: is the output of line 02?

let x = null
console.log(type of x);

A . ‘‘x’’
B . ‘‘null’’’
C . ‘‘object’’
D . ‘‘undefined’’

A

C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
75
Q

Which statement parses successfully?
A . JSON.parse ( ‘ foo ‘ );
B . JSON.parse ( ‘’ foo ‘’ );
C . JSON.parse( ‘’ ‘ foo ‘ ‘’ );
D . JSON.parse(‘ ‘’ foo ‘’ ‘);

A

D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
76
Q

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’);

A

D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
77
Q

A developer wants to use a try…catch statement to catch any error that countSheep () may throw and pass it to a
handleError () function.
What is the correct implementation of the try…catch?

A. Try{
setTimeout(function(){
countSheep(); ),1000);
} catch(e){
handleError(e)
}

B. try{
countSheep();
} finally {
handleerror(e)
}

C. setTimeout(function() {
try{
countsheep();
} catch(e) (
handleerror(e);
)},1000);

D Try{
countsheep();
}handleError(e){
catch(e);

A

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
78
Q

Which two console logs output NaN?
Choose 2 answers | |
A . console.log(10 / Number(‘5) ) ;
B . console.log(parseInt ‘ (‘two’)) ;
C . console.log(10 / 0);
D . console.loeg(10 / ‘five’);

A

B,D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
79
Q

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 ();

A

D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
80
Q

A developer wants to define a function log to be used a few times on a single-file JavaScript script.
01 // Line 1 replacement
02 console.log(‘‘LOG:’, logInput);
03 }

Which two options can correctly replace line 01 and declare the function for use?

Choose 2 answers
A . function leg(logInput) {
B . const log(loginInput) {
C . const log = (logInput) => {
D . function log = (logInput) {

A

A, C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
81
Q

Refer to the expression below:
Let x = (‘1’ + 2) == (6 * 2);

How should this expression be modified to ensure that evaluates to false?

A . Let x = (‘1’ + ‘ 2’) == ( 6 * 2);
B . Let x = (‘1’ + 2) == ( 6 * 2);
C . Let x = (1 + 2) == ( ‘6’ / 2);
D . Let x = (1 + 2 ) == ( 6 / 2);

A

B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
82
Q

A developer implements and calls the following code when an application state change occurs:
Const onStateChange =innerPageState) => {
window.history.pushState(newPageState, ‘ ‘, null);
}

If the back button is clicked after this method is executed, what can a developer expect?

A . A navigate event is fired with a state property that details the previous application state.

B . The page is navigated away from and the previous page in the browser’s history is loaded

C . The page reloads and all Javascript is reinitialized.

D . A popstate event is fired with a state property that details the application’s last state.

A

B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
83
Q

Refer to code below:
console.log(0);

setTimeout(() => (
console.log(1);
});

console.log(2);

setTimeout(() => {
console.log(3);
), 0);

console.log(4);

In which sequence will the numbers be logged?

A . 01234
B . 02431
C . 02413
D . 13024

A

C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
84
Q

Refer to code below:
Const objBook = {
Title: ‘Javascript’,
};
Object.preventExtensions(objBook);
Const newObjBook = objBook;

newObjectBook.author = ‘Robert’;

What are the values of objBook and newObjBook respectively ?

A . [title: ‘‘javaScript’’] [title: ‘‘javaScript’’]
B . {author: ‘‘Robert’’, title: ‘‘javaScript}
Undefined
C . {author: ‘‘Robert’’, title: ‘‘javaScript}
{author: ‘‘Robert’’, title: ‘‘javaScript}
D . {author: ‘‘Robert’’}
{author: ‘‘Robert’’, title: ‘‘javaScript}

A

A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
85
Q

Refer to the following array:
Let arr = [ 1,2, 3, 4, 5];

Which three options result in x evaluating as [3, 4, 5] ?

Choose 3 answers.

A . Let x= arr.filter (( a) => (a<2));
B . Let x= arr.splice(2,3);
C . Let x= arr.slice(2);
D . Let x= arr.filter((a) => ( return a>2 ));
E . Let x = arr.slice(2,3);

A

B,C,D

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
86
Q

In the browser, the window object is often used to assign variables that require the broadest scope in an application Node.js application does not have access to the window object by default.
Which two methods are used to address this ?

Choose 2 answers

A . Use the document object instead of the window object.
B . Assign variables to the global object.
C . Create a new window object in the root file.
D . Assign variables to module.exports and require them as needed.

A

B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
87
Q

Refer to the code below:
Const myFunction = arr => {
Return arr.reduce((result, current) =>{
Return result = current;
}, 10};
}

What is the output of this function when called with an empty array ?
A . Returns 0
B . Throws an error
C . Returns 10
D . Returns NaN

A

C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
88
Q

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 . localStorage.

A

A, B, E

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
89
Q

A developer has two ways to write a function:
Option A:
function Monster() {
This.growl = () => {
Console.log (‘‘Grr!’’);
}
}
Option B:
function Monster() {};
Monster.prototype.growl =() => {
console.log(‘‘Grr!’’);
}

After deciding on an option, the developer creates 1000 monster objects.

How many growl methods are created with Option A Option B?

A . 1 growl method is created for Option A. 1000 growl methods are created for Option B.
B . 1000 growl method is created for Option A. 1 growl methods are created for Option B.
C . 1000 growl methods are created regardless of which option is used.
D . 1 growl method is created regardless of which option is used.

A

B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
90
Q

Given the code below:
Setcurrent URL ();
console.log(‘The current URL is: ‘ +url );
function setCurrentUrl() {
Url = window.location.href:

What happens when the code executes?

A . The url variable has local scope and line 02 throws an error.
B . The url variable has global scope and line 02 executes correctly.
C . The url variable has global scope and line 02 throws an error.
D . The url variable has local scope and line 02 executes correctly.

A

B

91
Q

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

A

B

92
Q

Why would a developer specify a package.jason as a developed forge instead of a dependency ?

A . It is required by the application in production.
B . It is only needed for local development and testing.
C . Other required packages depend on it for development.
D . It should be bundled when the package is published.

A

B

93
Q

Refer to the code below:
Const searchTest = ‘Yay! Salesforce is amazing!’’ ;
Let result1 = searchText.search(/sales/i);
Let result 21 = searchText.search(/sales/i);

console.log(result1);
console.log(result2);

After running this code, which result is displayed on the console?
A . > true > false
B . > 5 >undefined
C . > 5 > -1
D . > 5 > 0

A

B

94
Q

Refer to the code below:
Const resolveAfterMilliseconds = (ms) => Promise.resolve (
setTimeout (( => console.log(ms), ms ));
Const aPromise = await resolveAfterMilliseconds(500);
Const bPromise = await resolveAfterMilliseconds(500);
Await aPromise, wait bPromise;

What is the result of running line 05?

A . aPromise and bPromise run sequentially.
B . Neither aPromise or bPromise runs.
C . aPromise and bPromise run in parallel.
D . Only aPromise runs.

A

B

95
Q

Refer to the following code that performs a basic mathematical operation on a provided
input:
function calculate(num) {
Return (num +10) / 3;
}

How should line 02 be written to ensure that x evaluates to 6 in the line below?

Let x = calculate (8);

A . Return Number((num +10) /3 );
B . Return (Number (num +10 ) / 3;
C . Return Integer(num +10) /3;
D . Return Number(num + 10) / 3;

A

B

96
Q

Refer to the code below:
function changeValue(param) {
Param =5;
}

Let a =10;
Let b =5;
changeValue(b);

Const result = a+ ‘’ - ‘’+ b;
What is the value of result when code executes?

A . 10 -10
B . 5 -5
C . 5 - 10
D . 10 - 5

A

A

97
Q

A developer implements a function that adds a few values.
Function sum(num) {
If (num == undefined) {
Num =0;
}
Return function( num2, num3){
If (num3 === undefined) {
Num3 =0 ;
}
Return num + num2 + num3;
}
}

Which three options can the developer invoke for this function to get a return value of 10 ?

Choose 3 answers

A . Sum () (20)
B . Sum (5, 5) ()
C . sum() (5, 5)
D . sum(5)(5)
E . sum(10) ()

A

C, D

98
Q

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

A,C

99
Q

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 to 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.addCallback(‘‘click’’, function() {
D . Replace line 02 with button.addEventListener(‘‘onclick’’, function() {

A

A

100
Q

What are two unique features of functions defined with a fat arrow as compared to normal function definition?

Choose 2 answers

A . The function generated its own this making it useful for separating the function’s scope from its enclosing
scope.
B . The function receives an argument that is always in scope, called parentThis, which is the enclosing lexical
scope.
C . If the function has a single expression in the function body, the expression will be evaluated and implicit
returned.
D . The function uses the this from the enclosing scope.

A

A, B

101
Q

A developer wants to leverage a module to print a price in pretty format, and has imported a method as shown
below:
Import printPrice from ‘/path/PricePrettyPrint.js’;
Based on the code, what must be true about the printPrice function of the PricePrettyPrint module for this import
to work ?

A . printPrice must be be a named export
B . printPrice must be an all export
C . printPrice must be the default export
D . printPrice must be a multi exportc

A

C

102
Q

Refer to HTML below:
The current status of an Order: <span id =’‘status’’> In Progress </span>
.
Which JavaScript statement changes the text ‘In Progress’ to ‘Completed’ ?

A . document.getElementById(‘‘status’’).Value = ‘Completed’ ;
B . document.getElementById(‘‘#status’’).innerHTML = ‘Completed’ ;
C . document.getElementById(‘‘status’’).innerHTML = ‘Completed’ ;
D . document.getElementById(‘‘.status’’).innerHTML = ‘Completed’ ;

A

C

103
Q

Refer to the code snippet below:
Let array = [1, 2, 3, 4, 4, 5, 4, 4];
For (let i =0; i < array.length; i++)
if (array[i] === 4) {
array.splice(i, 1);
}
}

What is the value of array after the code executes?

A . [1, 2, 3, 4, 5, 4, 4]
B . [1, 2, 3, 4, 4, 5, 4]
C . [1, 2, 3, 5]
D . [1, 2, 3, 4, 5, 4]

A

D

104
Q

A developer is setting up a new Node.js server with a client library that is built using events and callbacks.
The library:
Will establish a web socket connection and handle receipt of messages to the server
Will be imported with require, and made available with a variable called we.
The developer also wants to add error logging if a connection fails.
Given this info, which code segment shows the correct way to set up a client with two events that listen at
execution time?

A . ws.connect (( ) => {
console.log(‘connected to client’); }).catch((error) => { console.log(‘ERROR’ , error); }};

B . ws.on (‘connect’, ( ) => { console.log(‘connected to client’);
ws.on(‘error’, (error) => { console.log(‘ERROR’ , error); });
});

C . ws.on (‘connect’, ( ) => { console.log(‘connected to client’);
}};
ws.on(‘error’, (error) => { console.log(‘ERROR’ ,error);
}};

D . try{
ws.connect (( ) => {
console.log(‘connected to client’); });
Answer: B
Question: 104
} catch(error) { console.log(‘ERROR’ , error); };
}

A

C

105
Q

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’);

A

D

106
Q

Refer to the code below:
Let foodMenu1 = [‘pizza’, ‘burger’, ‘French fries’];
Let finalMenu = foodMenu1;
finalMenu.push(‘Garlic bread’);

What is the value of foodMenu1 after the code executes?

A . [ ‘pizza’,’Burger’, ‘French fires’, ‘Garlic bread’]
B . [ ‘pizza’,’Burger’, ‘French fires’]
C . [ ‘Garlic bread’ , ‘pizza’,’Burger’, ‘French fires’ ]
D . [ ‘Garlic bread’]

A

A

107
Q

developer has a web server running with Node.js. The command to start the web
server is node server,js. The web server started having latency issues. Instead of a one second
turn around for web requests, the developer now sees a five second turnaround,
Which command can the web developer run to see what the module is doing during the
latency period?

A . DEBUG = http, https node server.js
B . NODE_DEBUG =http, https node server.js
C . DEBUG =true node server.js
D . NODE_DEBUG =true node server.js

A

C

108
Q

Refer to the code below:
Let inArray =[ [ 1, 2 ] , [ 3, 4, 5 ] ];
Which two statements result in the array [1, 2, 3, 4, 5] ?

Choose 2 answers

A . [ ]. Concat.apply ([ ], inArray);
B . [ ]. Concat (… inArray);
C . [ ]. concat.apply(inArray, [ ]);
D . [ ]. concat ( [ ….inArray ] );

A

A,B

109
Q

Refer to the code below:
let timeFunction =() => {
console.log(‘Timer called.’’);
};
let timerId = setTimeout (timedFunction, 1000);
Which statement allows a developer to cancel the scheduled timed function?

A . removeTimeout(timedFunction);
B . removeTimeout(timerId);
C . clearTimeout(timerId);
D . clearTimeout(timedFunction);

A

C

110
Q

Refer to code below:
Let a =’a’;
Let b;
// b = a;
console.log(b);
What is displayed when the code executes?
A . ReferenceError: b is not defined
B . A
C . Undefined
D . Null

A

C

111
Q

Refer to the code below:
//<html lang=’‘en’’>
//<table onclick=’‘console.log(Table log’);’’>
//<tr id=’‘row1’’>
//<td>Click me!</td>
//</tr>
//<table>
//


function printMessage(event) {
console.log('Row log');
}
Let elem = document.getElementById('row1');
elem.addEventListener('click', printMessage, false);
//

//</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.

A

B

112
Q

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 >10){
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

A

113
Q

Which javascript methods can be used to serialize an object into a string and deserialize a JSON string into an object, respectively?

A . JSON.stringify and JSON.parse
B . JSON.serialize and JSON.deserialize
C . JSON.encode and JSON.decode
D . JSON.parse and JSON.deserialize

A

A

114
Q

Refer to code below:
Let first = ‘who’;
Let second = ‘what’;
Try{
Try{
Throw new error(‘Sad trombone’);
}catch (err){
First =’Why’;
}finally {
Second =’when’;
} catch (err) {
Second =’Where’;
}
What are the values for first and second once the code executes ?
A . First is Who and second is When
B . First is why and second is where
C . First is who and second is where
D . First is why and second is when

A

D

115
Q

Teams at Universal Containers (UC) work on multiple JavaScript projects at the same time.
UC is thinking about reusability and how each team can benefit from the work of others.
Going open-source or public is not an option at this time.
Which option is available to UC with npm?

A . Private packages can be scored, and scopes can be associated to a private registries.
B . Private registries are not supported by npm, but packages can be installed via URL.
C . Private packages are not supported, but they can use another package manager like yarn.
D . Private registries are not supported by npm, but packages can be installed via git.

A

A

116
Q

Which option is true about the strict mode in imported modules?

A . Add the statement use non-strict, before any other statements in the module to enable
not-strict mode.
B . You can only reference notStrict() functions from the imported module.
C . Imported modules are in strict mode whether you declare them as such or not.
D . Add the statement use strict =false; before any other statements in the module to enable
not- strict mode.

A

B

117
Q

Refer to the code snippet below:
Let array = [1, 2, 3, 4, 4, 5, 4, 4];
For (let i =0; i < array.length; i++){
if (array[i] === 4) {
array.splice(i, 1);
}
}

What is the value of the array after the code executes?
A . [1, 2, 3, 4, 5, 4, 4]
B . [1, 2, 3, 4, 4, 5, 4]
C . [1, 2, 3, 4, 5, 4]
D . [1, 2, 3, 5]

A

C

118
Q

Which option is a core Node,js module?

A . Path
B . Ios
C . Memory
D . locate

A

A

119
Q

Refer to following code:
class Vehicle {
constructor(plate) {
This.plate =plate;
}
}
Class Truck extends Vehicle {
constructor(plate, weight) {
//Missing code
This.weight = weight;
}
displayWeight() {
console.log(‘The truck ${this.plate} has a weight of ${this.weight} lb.’);}}
Let myTruck = new Truck(‘123AB’, 5000);
myTruck.displayWeight();
Which statement should be added to line 09 for the code to display ‘The truck 123AB has a
weight of 5000lb.’?

A . Super.plate =plate;
B . super(plate);
C . This.plate =plate;
D . Vehicle.plate = plate;

A

B

120
Q

Refer to the following object:
const cat ={
firstName: ‘Fancy’,
lastName: ‘ Whiskers’,
Get fullName() {
return this.firstName + ‘ ‘ + this.lastName;
}
};

How can a developer access the fullName property for cat?
A . cat.fullName
B . cat.fullName()
C . cat.get.fullName
D . cat.function.fullName()

A

A

121
Q

Universal Containers (UC) notices that its application that allows users to search for accounts makes a network request each time a key is pressed. This results in too many requests for the server to handle.
Address this problem, UC decides to implement a debounce function on string change
handler.

What are three key steps to implement this debounce function?

Choose 3 answers:

A . If there is an existing setTimeout and the search string change, allow the existing
setTimeout to finish, and do not enqueue a new setTimeout.
B . When the search string changes, enqueue the request within a setTimeout.
C . Ensure that the network request has the property debounce set to true.
D . If there is an existing setTimeout and the search string changes, cancel the existing
setTimeout using the persisted timerId and replace it with a new setTimeout.
E . Store the timeId of the setTimeout last enqueued by the search string change handle

A

A,B,C

122
Q

Refer to code below:
function Person() {
this.firstName = ‘John’;
}
Person.prototype ={
Job: x => ‘Developer’
};

const myFather = new Person();
const result =myFather.firstName + ‘ ‘ + myFather.job();

What is the value of the result after line 10 executes?

A . Error: myFather.job is not a function
B . Undefined Developer
C . John undefined
D . John Developer

A

D

123
Q

A developer is wondering whether to use, Promise.then or Promise.catch, especially
when a Promise throws an error?
Which two promises are rejected?
Which 2 are correct?

A . Promise.reject(‘cool error here’).then(error => console.error(error));
B . Promise.reject(‘cool error here’).catch(error => console.error(error));
C . New Promise((resolve, reject) => (throw ‘cool error here’}).catch(error =>
console.error(error)) ;
D . New Promise(() => (throw ‘cool error here’}).then(null, error => console.error(error)));

A

B,C

124
Q

developer is trying to convince management that their team will benefit from using
Node.js for a backend server that they are going to create. The server will be a web server that
handles API requests from a website that the team has already built using HTML, CSS, and
JavaScript.

Which three benefits of Node.js can the developer use to persuade their manager?

Choose 3 answers:

A . Installs with its own package manager to install and manage third-party libraries.
B . Ensures stability with one major release every few years.
C . Performs a static analysis on code before execution to look for runtime errors.
D . Executes server-side JavaScript code to avoid learning a new language.
E . Uses non-blocking functionality for performant request handling .

A

A,C,E

125
Q

Refer to HTML below:
This card is smaller.
The width and height of this card is determined by its contents.
Which expression outputs the screen width of the element with the ID card-01?
A . document.getElementById(‘ card-01 ‘).getBoundingClientRest().width
B . document.getElementById(‘ card-01 ‘).style.width
C . document.getElementById(‘ card-01 ‘).width
D . document.getElementById(‘ card-01 ‘).innerHTML.lenght*e

A

A

126
Q

Refer to the code below:
console.log(‘‘start);
Promise.resolve(‘Success’) .then(function(value){
console.log(‘Success’);
});
console.log(‘End’);
What is the output after the code executes successfully?

A . End
Start
Success
B . Start
Success
End
C . Start
End
Success
D . Success
Start
End

A

C

127
Q

Universal Container(UC) just launched a new landing page, but users complain that the website is slow. A developer found some functions that cause this problem. To verify this, the developer decides to do everything and log the time each of these three suspicious functions
consumes.

console.time(‘Performance’);
maybeAHeavyFunction();
thisCouldTakeTooLong();
orMaybeThisOne();
console.endTime(‘Performance’);

Which function can the developer use to obtain the time spent by every one of the three
functions?

A . console.timeLog()
B . console.getTime()
C . console.trace()
D . console.timeStamp()

A

A

128
Q

Given the following code:
document.body.addEventListener(‘ click ‘, (event) => {
if (/* CODE REPLACEMENT HERE */) {
console.log(‘button clicked!’);
)
});

Which replacement for the conditional statement on line 02 allows a developer to correctly determine that a button on page is clicked?

A . Event.clicked
B . e.nodeTarget ==this
C . event.target.nodeName == ‘BUTTON’
D . button.addEventListener(‘click’)

A

C

129
Q

Given the following code:
document.body.addEventListener(‘ click ‘, (event) => {
if (/* CODE REPLACEMENT HERE */) {
console.log(‘button clicked!’);
)
});

Which replacement for the conditional statement on line 02 allows a developer to correctly determine that a button on page is clicked?

A . Event.clicked
B . e.nodeTarget ==this
C . event.target.nodeName == ‘BUTTON’
D . button.addEventListener(‘click’)

A

C

130
Q

Refer to the code below:
function foo () {
const a =2;
function bat() {
console.log(a);
}
return bar;
}

Why does the function bar have access to variable a ?

A . Inner function’s scope
B . Hoisting
C . Outer function’s scope
D . Prototype chain

A

C

131
Q

Refer to the following code:
//<html lang=’‘en’’>
//<body>
//<button id =’‘myButton’‘>CLick me<button>
//</body>
//


function displayMessage(ev) {
ev.stopPropagation();
console.log('Inner message.');
}
const elem = document.getElementById('myButton');
elem.addEventListener('click' , displayMessage);
//

//</html></button>

What will the console show when the button is clicked?

A . Outer message
B . Outer message Inner message
C . Inner message Outer message
D . Inner message

A

D

132
Q

A developer receives a comment from the Tech Lead that the code given below has error:

const monthName = ‘July’;
const year = 2019;
if(year === 2019) {
monthName = ‘June’;
}

Which line edit should be made to make this code run?
A . 01 let monthName =’July’;
B . 02 let year =2019;
C . 02 const year = 2020;
D . 03 if (year == 2019) {

A

A

133
Q

The developer wants to test the array shown:
const arr = Array(5).fill(0)

Which two tests are the most accurate for this array ?
Choose 2 answers:

A . console.assert( arr.length === 5 );
B . arr.forEach(elem => console.assert(elem === 0)) ;
C . console.assert(arr[0] === 0 && arr[ arr.length] === 0);
D . console.assert (arr.length >0);

A

A, B

134
Q

Given the code below:
const copy = JSON.stringify([ new String(‘ false ‘), new Bollean( false ), undefined ]);

What is the value of copy?

A . – [ '‘false'’ , { } ]–
B . – [ false, { } ]–
C . – [ '‘false'’ , false, undefined ]–
D . – [ '‘false'’ ,false, null ]–

A

D

135
Q

Which code statement below correctly persists an objects in local Storage ?

A . const setLocalStorage = (storageKey, jsObject) => {
window.localStorage.setItem(storageKey, JSON.stringify(jsObject));
}
B . const setLocalStorage = ( jsObject) => {
window.localStorage.connectObject(jsObject));
}
C . const setLocalStorage = ( jsObject) => {
window.localStorage.setItem(jsObject);
}
D . const setLocalStorage = (storageKey, jsObject) => {
window.localStorage.persist(storageKey, jsObject);
}

A

A

136
Q

Refer to the following code:

function test (val) {
If (val === undefined) {
return ‘Undefined values!’ ;
}
if (val === null) {
return ‘Null value! ‘;
}
return val;
}

Let x;
test(x);

What is returned by the function call on line 13?
A . Undefined
B . Line 13 throws an error.
C . ‘Undefined values!’
D . ‘Null value!’

A

C

137
Q

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. Given the code and the information, the developer has, which code logs an error at boost with an event?

A . Server.catch ((server) => {
console.log(‘ERROR’, error);
});
B . Server.error ((server) => {
console.log(‘ERROR’, error);
});
C . Server.on (‘error’, (error) => {
console.log(‘ERROR’, error);
});
D . Try{
server.start();
} catch(error) {
console.log(‘ERROR’, error);
}

A

C

138
Q

Refer to the following code that imports a module named utils:
import (foo, bar) from ‘/path/Utils.js’;
foo() ;
bar() ;

Which two implementations of Utils.js export foo and bar such that the code above runs without
error?

Choose 2 answers

A . // FooUtils.js and BarUtils.js exist
Import (foo) from ‘/path/FooUtils.js’;
Import (boo) from ‘ /path/NarUtils.js’;
B . const foo = () => { return ‘foo’ ; }
const bar = () => { return ‘bar’ ; }
export { bar, foo }
C . Export default class {
foo() { return ‘foo’ ; }
bar() { return ‘bar’ ; }
}
D . const foo = () => { return ‘foo’;}
const bar = () => {return ‘bar’; }
Export default foo, bar;

A

B,C

139
Q

What is the result of the code block?

A . The console logs only ‘flag’.
B . The console logs ‘flag’ and another flag.
C . An error is thrown.
D . The console logs ‘flag’ and then an error is thrown.

A

D

140
Q

Refer to the code below:
let sayHello = () => {
console.log (‘Hello, world!’);
};

Which code executes sayHello once, two minutes from now?

A . setTimeout(sayHello, 12000);
B . setInterval(sayHello, 12000);
C . setTimeout(sayHello(), 12000);
D . delay(sayHello, 12000);

A

A

141
Q

A developer has the function, shown below, that is called when a page loads.
function onload() {
console.log(‘‘Page has loaded!’’);
}

Where can the developer see the log statement after loading the page in the browser?

A . Terminal running the web server.
B . Browser performance toots
C . Browser javaScript console
D . On the webpage.

A

C

142
Q

The developer has a function that prints ‘‘Hello’’ to an input name. To test this, thedeveloper created a function that returns ‘‘World’’.

However the following snippet does not print ‘’ Hello World’’.

const sayHello = (name) => {
console.log(“Hello”, name());
}

const world = () => {
return world;
};

What can the developer do to change the code to print ‘‘Hello World’’ ?
A . Change line 7 to ) () ;
B . Change line 2 to console.log(‘Hello’ , name() );
C . Change line 9 to sayHello(world) ();
D . Change line 5 to function world ( ) {

A

B

143
Q

A developer has code that calculates a restaurant bill, but generates incorrect answers
while testing the code:
function calculateBill ( items ) {
let total = 0;
total += findSubTotal(items);
total += addTax(total);
total += addTip(total);
return total;
}

Which option allows the developer to step into each function execution within calculateBill?

A . Using the debugger command on line 05.
B . Using the debugger command on line 03
C . Calling the console.trace (total) method on line 03.
D . Wrapping findSubtotal in a console.log() method.

A

A

144
Q

A developer wrote a fizzbuzz function that when passed in a number, returns the following:

‘Fizz’ if the number is divisible by 3.
‘Buzz’ if the number is divisible by 5.
‘Fizzbuzz’ if the number is divisible by both 3 and 5.
Empty string if the number is divisible by neither 3 or 5.

Which two test cases will properly test scenarios for the fizzbuzz function?

Choose 4 answers

A . let res = fizzbuzz(5);
console.assert ( res === ‘ ‘ );
B . let res = fizzbuzz(15);
console.assert ( res === ‘ fizzbuzz ‘ )
C . let res = fizzbuzz(Infinity);
console.assert ( res === ‘ ‘ )
D . let res = fizzbuzz(3);
console.assert ( res === ‘ buzz ‘ )

A

B,C,D

145
Q

Considering type coercion, what does the following expression evaluate to?

True + ‘13’ + NaN

A . ‘ 113Nan ‘
B . 14
C . ‘ true13 ‘
D . ‘ true13NaN ‘

A

D

146
Q

Refer to the HTML below:
//<ul>
//<li>Leo</li>
//<li>Tony</li>
//<li>Tiger</li>
//</ul>

Which JavaScript statement results in changing ‘’ Tony’’ to ‘‘Mr. T.’’?

A . document.querySelectorAll(‘$main $TONY’).innerHTML = ‘ Mr. T. ‘;
B . document.querySelector(‘$main li:second-child’).innerHTML = ‘ Mr. T. ‘;
C . document.querySelector(‘$main li.Tony’).innerHTML = ‘ Mr. T. ‘;
D . document.querySelector(‘$main li:nth-child(2)’),innerHTML = ‘ Mr. T.’;

A

D

147
Q

Which two code snippets show working examples of a recursive function?

Choose 2 answers

A . Let countingDown = function(startNumber) {
If ( startNumber >0) {
console.log(startNumber) ;
return countingDown(startNUmber);
} else {
return startNumber;
}};

B . Function factorial ( numVar ) {
If (numVar < 0) return;
If ( numVar === 0 ) return 1;
return numVar -1;

C . Const sumToTen = numVar => {
If (numVar < 0)
Return;
return sumToTen(numVar + 1)};

D . Const factorial =numVar => {
If (numVar < 0) return;
If ( numVar === 0 ) return 1;
return numVar * factorial ( numVar - 1 );
};

A

A,D

148
Q

developer removes the HTML class attribute from the checkout button, so now it is
simply:
<button>Checkout</button>.
There is a test to verify the existence of the checkout button, however it looks for a button with
class= ‘‘blue’’. The test fails because no such button is found.
Which type of test category describes this test?

A . True positive
B . True negative
C . False positive
D . False negative

A

D

149
Q

A developer wants to create an object from a function in the browser using the code below:

Function Monster() { this.name = ‘hello’ };
Const z = Monster();

What happens due to lack of the new keyword on line 02?

A . The z variable is assigned the correct object.
B . The z variable is assigned the correct object but this.name remains undefined.
C . Window.name is assigned to ‘hello’ and the variable z remains undefined.
D . Window.m is assigned the correct object.

A

C

150
Q

Refer to code below:
Function muFunction(reassign){
Let x = 1;
var y = 1;

if( reassign ) {
Let x= 2;
Var y = 2;
console.log(x);
console.log(y);}
console.log(x);
console.log(y);
}

What is displayed when myFunction(true) is called?

A . 2 2 1 1
B . 2 2 undefined undefined
C . 2 2 1 2
D . 2 2 2 2

A

C

151
Q

Refer to the following array:

Let arr1 = [ 1, 2, 3, 4, 5 ];

Which two lines of code result in a second array, arr2 being created such that arr2 is not a reference to arr1?

A . Let arr2 = arr1.slice(0, 5);
B . Let arr2 = Array.from(arr1);
C . Let arr2 = arr1;
D . Let arr2 = arr1.sort();

A

A,B

152
Q

Refer to the code below:
new Promise((resolve, reject) => {
const fraction = Math.random();
if( fraction >0.5) reject(‘fraction > 0.5, ‘ + fraction);
resolve(fraction);
})
.then(() =>console.log(‘resolved’))
.catch((error) => console.error(error))
.finally(() => console.log(‘ when am I called?’));

When does Promise.finally on line 08 get called?
A . When rejected
B . When resolved and settled
C . When resolved
D . When resolved or rejected

A

D

153
Q

Refer to the code below:
Let str = ‘javascript’;
Str[0] = ‘J’;
Str[4] = ‘S’;

After changing the string index values, the value of str is ‘javascript’. What is the reason for this value:

A . Non-primitive values are mutable.
B . Non-primitive values are immutable.
C . Primitive values are mutable.
D . Primitive values are immutable.

A

D

154
Q

Refer to the code below:

let greeting = ‘GoodBye’;
let salutation = ‘‘Hello, hello, hello’;
try{
greeting = Hello;
decodeURI(%%%%)
salutation = ‘GoodBye’;
}catch(err){
salutation = ‘I say Hello’;
}finally{
salutation = hello hello;
}

Line 05 causes an error.

What are the values of greeting and salutation once code completes?

A . Greeting is Hello and salutation is Hello, Hello.
B . Greeting is Goodbye and salutation is Hello, Hello.
C . Greeting is Goodbye and salutation is I say Hello.
D . Greeting is Hello and salutation is I say hello.

A

A

155
Q

Cloud Kicks has a class to represent items for sale in an online store, as shown below:
Class Item{

constructor (name, price){
this.name = name;
this.price = price;
}
formattedPrice(){
return ‘s’ + String(this.price);}}

A new business requirement comes in that requests a ClothingItem class that should have all of
the properties and methods of the Item class but will also have properties that are specific to
clothes.

Which line of code properly declares the clothingItem class such that it inherits from Item?

A . Class ClothingItem implements Item{
B . Class ClothingItem {
C . Class ClothingItem super Item {
D . Class ClothingItem extends Item {

A

D

156
Q

Given two expressions var1 and var2. What are two valid ways to return the logical AND
of the two expressions and ensure it is data type Boolean ?

Choose 2 answers:

A . Boolean(var1 && var2)
B . var1 && var2
C . var1.toBoolean() && var2toBoolean()
D . Boolean(var1) && Boolean(var2)

A

A,D

157
Q

Refer to the following code:
Let sampleText = ‘The quick brown fox jumps’;

A developer needs to determine if a certain substring is part of a string.
Which three expressions return true for the given substring ?

Choose 3 answers

A . sampleText.includes(‘fox’);
B . sampleText.includes(‘ quick ‘, 4);
C . sampleText.includes(‘ Fox ‘, 3)
D . sampleText.includes(‘ fox ‘);
E . sampleText.includes(‘ quick ‘) !== -1;

A

B,D,E

158
Q

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.

A

B

159
Q

Refer to the code:

function Animal (size, type) {

this.size = size || ‘small’;
this.type = type || ‘Animal’;
this.cantalk = false;
}

let pet = function (size, type, name, owner){
Animal.call(this, size, type);

this.name = name;
this.owner = owner;

pet prototype = object.create(Animal.prototype);
let pet1 = new Pet();

console.log(pet1);

Given the code above, which three properties are set pet1?

Choose 3 answers:

A . Name
B . canTalk
C . Type
D . Owner
E . Size

A

B,C,E

160
Q

A developer wrote the following code:
01 let X = object.value;
02
03 try {
04 handleObjectValue(X);
05 } catch (error) {
06 handleError(error);
07 }

The developer has a getNextValue function to execute after handleObjectValue(), but does not want to execute getNextValue() if an error occurs.
How can the developer change the code to ensure this behavior?
A . 03 try{
04 handleObjectValue(x);
05 } catch(error){
06 handleError(error);
07 } then {
08 getNextValue();
09 }

B . 03 try{
04 handleObjectValue(x);
05 } catch(error){
06 handleError(error);
07 } finally {
08 getNextValue();
10 }

C . 03 try{
04 handleObjectValue(x);
05 } catch(error){
06 handleError(error);
07 }
08 getNextValue();

D . 03 try {
04 handleObjectValue(x)
05 ……………………

A

D

161
Q

A developer creates a generic function to log custom messages in the console. To do this, the function below is implemented.

01 function logStatus(status){
02 console./Answer goes here/{‘Item status is: %s’, status};
03 }

Which three console logging methods allow the use of string substitution in line 02?

A . Assert
B . Log
C . Message
D . Info
E . Error

A

B,D,E

Double check

162
Q

is below:
<input type=’‘file’’ onchange=’‘previewFile()’’>
The JavaScript portion is:
01 function previewFile(){
02 const preview = document.querySelector(‘img’);
03 const file = document.querySelector(‘input[type=file]’).files[0];
04 //line 4 code
05 reader.addEventListener(‘‘load’’, () => {
06 preview.src = reader.result;
07 },false);
08 //line 8 code
09 }

In lines 04 and 08, which code allows the user to select an image from their local computer , and to display the image in the browser?

A . 04 const reader = new File();
08 if (file) URL.createObjectURL(file);
B . 04 const reader = new FileReader();
08 if (file) URL.createObjectURL(file);
C . 04 const reader = new File();
08 if (file) reader.readAsDataURL(file);
D . 04 const reader = new FileReader();
08 if (file) reader.readAsDataURL(file);

A

D

163
Q

Which code statement correctly retrieves and returns an object from localStorage?

A . const retrieveFromLocalStorage = () =>{
return JSON.stringify(window.localStorage.getItem(storageKey));
}

B . const retrieveFromLocalStorage = (storageKey) =>{
return window.localStorage.getItem(storageKey);
}

C . const retrieveFromLocalStorage = (storageKey) =>{
return JSON.parse(window.localStorage.getItem(storageKey));
}

D . const retrieveFromLocalStorage = (storageKey) =>{
return window.localStorage[storageKey];
}

A

C

164
Q

Universal Containers recently launched its new landing page to host a crowd-funding campaign. The page uses an external library to display some third-party ads. Once the page is
fully loaded, it creates more than 50 new HTML items placed randomly inside the DOM, like the one in the code below:

//<div class = 'ad=libary-item ad-hidden' onload="myFunction()">
// <img></img>
//</div>

All the elements includes the same ad-library-item class, They are hidden by default, and they are randomly
displayed while the user navigates through the page.

A . Use the DOM inspector to prevent the load event to be fired.
B . Use the browser to execute a script that removes all the element containing the class ad-library-item.
C . Use the DOM inspector to remove all the elements containing the class ad-library-item.
D . Use the browser console to execute a script that prevents the load event to be fired.

A

C

165
Q

A developer is leading the creation of a new browser application that will serve a single page application. The team wants to use a new web framework Minimalsit.js. The Lead developer wants to advocate for a more seasoned web framework that already has a community around it.

Which two frameworks should the lead developer advocate for?

Choose 2 answers

A . Vue
B . Angular
C . Koa
D . Express

A

B,D

166
Q

A developer at Universal Containers creates a new landing page based on HTML, CSS, and JavaScript TO ensure that visitors have a good experience, a script named personaliseContext needs to be executed when the webpage is fully loaded (HTML content and all related files ), in order to do some custom initialization.

Which statement should be used to call personalizeWebsiteContent based on the above business requirement?

A . document.addEventListener(‘‘onDOMContextLoaded’, personalizeWebsiteContext);
B . window.addEventListener(‘load’,personalizeWebsiteContext);
C . window.addEventListener(‘onload’, personalizeWebsiteContext);
D . Document.addEventListener(‘'’DOMContextLoaded’ , personalizeWebsiteContext);

A

B

167
Q

Refer to the code below:
Function Person(firstName, lastName, eyecolor) {
this.firstName =firstName;
this.lastName = lastName;
this.eyeColor = eyeColor;
}

Person.job = ‘Developer’;
const myFather = new Person(‘John’, ‘Doe’);
console.log(myFather.job);

What is the output after the code executes?

A . ReferenceError: eyeColor is not defined
B . ReferenceError: assignment to undeclared variable ‘‘Person’’
C . Developer
D . Undefined

A

D

168
Q

Given the following code:
Counter = 0;
const logCounter = () => {
console.log(counter);
);

logCounter();
setTimeout(logCOunter, 1100);
setInterval(() => {
Counter++
logCounter();
}, 1000);

What is logged by the first four log statements?

A . 0 0 1 2
B . 0 1 2 3
C . 0 1 1 2
D . 0 1 2 2

A

C

169
Q

Which two console logs outputs NaN ?
Choose 2 answers

A . console.log(10/ Number(‘5’));
B . console.log(parseInt(‘two’));
C . console.log(10/ ‘‘five);
D . console.log(10/0);

A

B,C

170
Q

Given the code below:
Function myFunction(){
A =5;
Var b =1;
}
myFunction();
console.log(a);
console.log(b);

What is the expected output?

A . Both lines 08 and 09 are executed, and the variables are outputted.
B . Line 08 outputs the variable, but line 09 throws an error.
C . Line 08 thrones an error, therefore line 09 is never executed.
D . Both lines 08 and 09 are executed, but values outputted are undefined.

A

B

171
Q

Which statement accurately describes an aspect of promises?

A . Arguments for the callback function passed to .then() are optional.
B . In a.then() function, returning results is not necessary since callbacks will catch the result of a previous
promise.
C . .then() cannot be added after a catch.
D . .then() manipulates and returns the original promise.

A

A

172
Q

Refer to the following code:

01 function Tiger(){
02 this.Type = ‘Cat’;
03 this.size = ‘large’;
04 }
05
06 let tony = new Tiger();
07 tony.roar = () =>{
08 console.log(‘They're great1’);
09 };
10
11 function Lion(){
12 this.type = ‘Cat’;
13 this.size = ‘large’;
14 }
15
16 let leo = new Lion();
17 //Insert code here
18 leo.roar();

Which two statements could be inserted at line 17 to enable the function call on line 18?

Choose 2 answers.

A . Leo.roar = () => { console.log(‘They're pretty good:’); };
B . Object.assign(leo,Tiger);
C . Object.assign(leo,tony);
D . Leo.prototype.roar = () => { console.log(‘They're pretty good:’); };

A

A,C

173
Q

Given the following code:
Let x =(‘15’ + 10)*2;
What is the value of a?

A . 3020
B . 1520
C . 50
D . 35

A

A

174
Q

A class was written to represent items for purchase in an online store, and a second class
Representing items that are on sale at a discounted price. THe constructor sets the name to the
first value passed in. The pseudocode is below:
Class Item {
constructor(name, price) {
… // Constructor Implementation
}
}
Class SaleItem extends Item {
constructor (name, price, discount) {
…//Constructor Implementation
}
}
There is a new requirement for a developer to implement a description method that will return a
brief description for Item and SaleItem.
Let regItem =new Item(‘Scarf’, 55);
Let saleItem = new SaleItem(‘Shirt’ 80, -1);
Item.prototype.description = function () { return ‘This is a ‘ + this.name;
console.log(regItem.description());
console.log(saleItem.description());
SaleItem.prototype.description = function () { return ‘This is a discounted ‘ +
this.name; }
console.log(regItem.description());
console.log(saleItem.description());
What is the output when executing the code above ?

A . This is a Scarf
Uncaught TypeError: saleItem.description is not a function
This is aScarf
This is a discounted Shirt

B . This is a Scarf
This is a Shirt
This is a Scarf
This is a discounted Shirt

C . This is a Scarf
This is a Shirt
This is a discounted Scarf
This is a discounted Shirt

D . This is aScarf
Uncaught TypeError: saleItem.description is not a function
This is a Shirt
This is a did counted Shirt

A

B

175
Q

In which situation should a developer include a try .. catch block around their function call ?

A . The function has an error that should not be silenced.
B . The function results in an out of memory issue.
C . The function might raise a runtime error that needs to be handled.
D . The function contains scheduled code.

A

C

176
Q

Which three actions can be using the JavaScript browser console?
Choose 3 answers:

A . View and change DOM the page.
B . Display a report showing the performance of a page.
C . Run code that is not related to page.
D . view , change, and debug the JavaScript code of the page.
E . View and change security cookies.

A

A,C,D

177
Q

Refer to the code below?
Let searchString = ‘ look for this ‘;
Which two options remove the whitespace from the beginning of searchString?

Choose 2 answers

A . searchString.trimEnd();
B . searchString.trimStart();
C . trimStart(searchString);
D . searchString.replace(/\s\s/, ‘’);

A

B,D

178
Q

Refer to the following code:
Let obj ={
Foo: 1,
Bar: 2
}
Let output =[],
for(let something in obj{
output.push(something);
}
console.log(output);

What is the output line 11?

A . [1,2]
B . ['’bar’’,’‘foo’’]
C . ['’foo’’,’‘bar’’]
D . ['’foo:1’’,’‘bar:2’’]

A

C

179
Q

Given the code below:
const delay = sync delay => {
Return new Promise((resolve, reject) => {
setTimeout (resolve, delay);});};
const callDelay =async () =>{
const yup =await delay(1000);
console.log(1);

What is logged to the console?

A . 1 2 3
B . 1 3 2
C . 2 1 3
D . 2 3 1

A

D

180
Q

A developer wants to set up a secure web server with Node.js. The developer creates a
directory locally called app-server, and the first file is app-server/index.js

Without using any third-party libraries, what should the developer add to index.js to create the secure web server?

A . const https =require(‘https’);
B . const server =require(‘secure-server’);
C . const tls = require(‘tls’);
D . const http =require(‘http’);

A

A

181
Q

Refer to the code snippet:
Function getAvailabilityMessage(item) {
If (getAvailability(item)){
Var msg =’‘Username available’’;
}
Return msg;
}
A developer writes this code to return a message to user attempting to register a new
username. If the username is available, variable.
What is the return value of msg hen getAvailabilityMessage (‘‘newUserName’’ ) is executed and getAvailability(‘‘newUserName’’) returns false?

A . ‘‘Username available’’
B . ‘‘newUserName’’
C . ‘‘Msg is not defined’’
D . undefined

A

D

182
Q

developer wants to use a module named universalContainersLib and them call functions from it.

How should a developer import every function from the module and then call the fuctions foo
and bar ?

A . import * ad lib from ‘/path/universalContainersLib.js’;
lib.foo();
lib.bar();
B . import (foo, bar) from ‘/path/universalContainersLib.js’;
foo();
bar();
C . import all from ‘/path/universalContaineraLib.js’;
universalContainersLib.foo();
universalContainersLib.bar();
D . import * from ‘/path/universalContaineraLib.js’;
universalContainersLib.foo();
universalContainersLib.bar();

A

A

183
Q

GIven a value, which three options can a developer use to detect if the value is NaN?

Choose 3 answers

A . value == NaN
B . Object.is(value, NaN)
C . value === Number.NaN
D . value ! == value
E . Number.isNaN(value)

A

A, B, E

184
Q

Refer to the code below:
const addBy = ?
const addByEight =addBy(8);
const sum = addBYEight(50);
Which two functions can replace line 01 and return 58 to sum?

Choose 2 answers

A . const addBy = function(num1){
return function(num2){
return num1 + num2;
}

B . const addBy = function(num1){
return num1 + num2;
}

C . const addBy = (num1) => num1 + num2 ;

D . const addBY = (num1) => (num2) => num1 + num2;

A

A,D

185
Q

Given HTML below:

<div>

<div id =”row-uc”> Universal Container</div>

<div id =”row-aa”>Applied Shipping</div>

<div id =”row-bt”> Burlington Textiles </div>

</div>

Which statement adds the priority = account CSS class to the universal Containers row ?

A . Document .querySelector(‘#row-uc’).classes.push(‘priority-account’);
B . Document .queryElementById(‘row-uc’).addclass(‘priority-account’);
C . Document .querySelector(‘#row-uc’).classList.add(‘priority-account’);
D . Document .querySelectorALL(‘#row-uc’).classList.add(‘priority-account’);

A

B

186
Q

Refer to the code below:
Function changeValue(obj) {
Obj.value = obj.value/2;
}
Const objA = (value: 10);
Const objB = objA;
changeValue(objB);
Const result = objA.value;

What is the value of result after the code executes?

A . 10
B . Nan
C . 5
D . Undefined

A

C

187
Q

Which function should a developer use to repeatedly execute code at a fixed interval ?

A . setIntervel
B . setTimeout
C . setPeriod
D . setInteria

A

A

188
Q

Given the following code:
Let x =null;
console.log(typeof x);

What is the output of the line 02?

A . ‘‘Null’’
B . ‘‘X’’
C . ‘‘Object’’
D . ‘‘undefined’’

A

C

189
Q

A developer writers the code below to calculate the factorial of a given number.

Function factorial(number) {
Return number + factorial(number -1);
}
factorial(3);

What is the result of executing line 04?

A . 0
B . 6
C . -Infinity
D . RuntimeError

A

D

190
Q

Refer to the code below:
Let textValue = ‘1984’;

Which code assignment shows a correct way to convert this string to an integer?

A . let numberValue = Number(textValue);
B . Let numberValue = (Number)textValue;
C . Let numberValue = textValue.toInteger();
D . Let numberValue = Integer(textValue);

A

A

191
Q

At Universal Containers, every team has its own way of copying JavaScript objects. The
code Snippet shows an implementation from one team:

Function Person() {
this.firstName = ‘‘John’’;
this.lastName = ‘Doe’;
This.name =() => (
console.log(‘Hello $(this.firstName) $(this.firstName)’);
)}

Const john = new Person ();
Const dan = JSON.parse(JSON.stringify(john));
dan.firstName =’Dan’;
dan.name();

What is the Output of the code execution?

A . Hello Dan Doe
B . Hello John Doe
C . TypeError: dan.name is not a function
D . TypeError: Assignment to constant variable

A

C

192
Q

A developer is asked to fix some bugs reported by users. To do that, the developer adds a breakpoint for debugging.

Function Car (maxSpeed, color){
This.maxspeed =masSpeed;
This.color = color;
Let carSpeed = document.getElementById(‘ CarSpeed’);
Debugger;
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 ?

Choose 2 answers:

A . The values of the carSpeed and fourWheels variables
B . A variable displaying the number of instances created for the Car Object.
C . The style, event listeners and other attributes applied to the carSpeed DOM element
D . The information stored in the window.localStorage property

A

C,D

193
Q

A team that works on a big project uses npm to deal with projects dependencies. A developer added a dependency does not get downloaded when they execute npm
install.

Which two reasons could be possible explanations for this?

Choose 2 answers

A . The developer missed the option –add when adding the dependency.
B . The developer added the dependency as a dev dependency, and
NODE_ENV
Is set to production.
C . The developer missed the option –save when adding the dependency.
D . The developer added the dependency as a dev dependency, and
NODE_ENV is set to production.

A

B,C,D

194
Q

A developer has an ErrorHandler module that contains multiple functions.

What kind of export be leverages so that multiple functions can be used?

A . Named
B . All
C . Multi
D . Default

A

A

195
Q

A developer creates an object where its properties should be immutable and prevent
properties from being added or modified.

Which method should be used to execute this business requirement ?

A . Object.const()
B . Object.eval()
C . Object.lock()
D . Object.freeze()

A

D

196
Q

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

A

197
Q

A Developer wrote the following code to test a sum3 function that takes in an array of numbers and returns the sum of the first three number in the array, The test passes:

Let res = sum2([1, 2, 3 ]) ;
console.assert(res === 6 );
Res = sum3([ 1, 2, 3, 4]);
console.assert(res=== 6);

A different developer made changes to the behavior of sum3 to instead sum all of the numbers
present in the array. The test passes:
Which two results occur when running the test on the updated sum3 function?

Choose 2 answers

A . The line 02 assertion passes.
B . The line 02 assertion fails
C . The line 05 assertion passes
D . The line 05 assertion fails.

A

A,D

198
Q

Consider type coercion, what does the following expression evaluate to?

True + 3 + ‘100’ + null

A . 104
B . 4100
C . ‘3100null’
D . ‘4100null’

A

D

199
Q

Refer to the code below:
Async funct on functionUnderTest(isOK) {
If (isOK) return ‘OK’ ;
Throw new Error(‘not OK’);
)

Which assertion accurately tests the above code?

A . Console.assert (functionUnderTest(true), ‘OK’)
B . Console.assert (await functionUnderTest(true), ‘ not OK ‘)
C . Console.assert (await functionUnderTest(true), ‘ not OK ‘)
D . Console.assert (await functionUnderTest(true), ‘OK’)

A

D

200
Q

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

A

D

201
Q

Which statement accurately describes the behaviour of the async/ await keywords ?

A . The associated class contains some asynchronous functions.
B . The associated function will always return a promise
C . The associated function can only be called via asynchronous methods
D . The associated sometimes returns a promise.

A

B

202
Q

Given code below:
setTimeout (() => (
console.log(1);
). 0);
console.log(2);
New Promise ((resolve, reject )) = > (
setTimeout(() => (
reject(console.log(3));
). 1000);
)).catch(() => (
console.log(4);
));
console.log(5);

What is logged to the console?

A . 2 1 4 3 5
B . 2 5 1 3 4
C . 1 2 4 3 5
D . 1 2 5 3 4

A

B

203
Q

A developer is required to write a function that calculates the sum of elements in an array but is getting undefined every time the code is executed. The developer needs to find what is missing in the code below.

Const sumFunction = arr => {
Return arr.reduce((result, current) => {
//
Result += current;
//
), 10);
);

Which option makes the code work as expected?

A . Replace line 02 with return arr.map(( result, current) => (
B . Replace line 04 with result = result +current;
C . Replace line 03 with if(arr.length == 0 ) ( return 0; )
D . Replace line 05 with return result;

A

D

204
Q

Refer to the code below:
Const pi = 3.1415326,

What is the data type of pi?

A . Double
B . Number
C . Decimal
D . Float

A

B

205
Q

Refer to the code below:

const event = new CustomEvent(
//Missing Code
);

obj.dispatchEvent(event);

A developer needs to dispatch a custom event called update to send information about recorded.

Which two options could a developer insert at the placeholder in line 02 to achieve this?

Choose 2 answers

A . ‘Update’ , (
recordId : ‘123abc’
(
B . ‘Update’ , ‘123abc’
C . { type : ‘update’, recordId : ‘123abc’ }
D . ‘Update’ , {
Details : {
recordId : ‘123abc’
}
}

A

A,D

206
Q

Which three options show valid methods for creating a fat arrow function?

Choose 3 answers

A . x => ( console.log(‘ executed ‘) ; )
B . [ ] => ( console.log(‘ executed ‘) ;)
C . ( ) => ( console.log(‘ executed ‘) ;)
D . X,y,z => ( console.log(‘ executed ‘) ;)
E . (x,y,z) => ( console.log(‘ executed ‘) ;)

A

A,E

207
Q

A developer creates a class that represents a blog post based on the requirement that a Post should have a body author and view count.

The Code shown Below:

Class Post {
// Insert code here
This.body =body
This.author = author;
this.viewCount = viewCount;
}
}

Which statement should be inserted in the placeholder on line 02 to allow for a variable to be set
to a new instanceof a Post with the three attributes correctly populated?

A . super (body, author, viewCount) {
B . Function Post (body, author, viewCount) {
C . constructor (body, author, viewCount) {
D . constructor() {

A

C

208
Q

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

A

B

209
Q

Refer to the code below:

01 const server = require(‘server’);
02 /* Insert code here */

A developer imports a library that creates a web server. The imported library uses events and callbacks to start the servers
Which code should be inserted at the line 03 to set up an event and start the web server ?

A . Server.start ();
B . server.on(‘ connect ‘ , ( port) => {
console.log(‘Listening on ‘ , port) ;})
C . server()
D . serve(( port) => (
E . console.log( ‘Listening on ‘, port) ;

A

B

210
Q

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

A,C

211
Q

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 alert ( ‘Hey! I am John Doe’) ;
03 button.addEventListener (‘click’, listen);
Which two code lines make this code work as required?
Choose 2 answers

A . On line 02, use event.first to test if it is the first execution.
B . On line 04, use event.stopPropagation ( ),
C . On line 04, use button.removeEventListener(‘ click’’ , listen);
D . On line 06, add an option called once to button.addEventListener().

A

C,D

212
Q

developer publishes a new version of a package with new features that do not break backward compatibility. The previous version number was 1.1.3.

Following semantic versioning format, what should the new package version number be?

A . 2.0.0
B . 1.2.3
C . 1.1.4
D . 1.2.0

A

D

213
Q

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 ‘

A

B

214
Q

A test has a dependency on database.query. During the test the dependency is replaced
with an object called database with the method, query, that returns an array. The developer needs to verify how many times the method was called and the arguments used each time.

Which two test approaches describe the requirement?

Choose 2 answers
A . Integration
B . Black box
C . White box
D . Mocking

A

C,D

215
Q

A developer has the following array of student test grades:
Let arr = [ 7, 8, 5, 8, 9 ];

The Teacher wants to double each score and then see an array of the students who scored more than 15 points.

How should the developer implement the request?

A . Let arr1 = arr.filter(( val) => ( return val > 15 )) .map (( num) => ( return num *2 ))
B . Let arr1 = arr.mapBy (( num) => ( return num 2 )) .filterBy (( val ) => return val > 15 )) ;
C . Let arr1 = arr.map((num) => num
2). Filter (( val) => val > 15);
D . Let arr1 = arr.map((num) => ( num *2)).filterBy((val) => ( val >15 ));

A

C

216
Q

Given the code below:
01 function GameConsole (name) {
02 this.name = name;
03 }
04
05 GameConsole.prototype.load = function(gamename) {
06 console.log( ` $(this.name) is loading a game : $(gamename) …); 07 ) 08 function Console 16 Bit (name) { 09 GameConsole.call(this, name) ; 10 } 11 Console16bit.prototype = Object.create ( GameConsole.prototype) ; 12 //insert code here 13 console.log( $(this.name) is loading a cartridge game : $(gamename) …`);
14 }
15 const console16bit = new Console16bit(‘ SNEGeneziz ‘);
16 console16bit.load(‘ Super Nonic 3x Force ‘);

What should a developer insert at line 15 to output the following message using the method?

> SNEGeneziz is loading a cartridge game: Super Monic 3x Force . . .

A . Console16bit.prototype.load(gamename) = function() {
B . Console16bit.prototype.load = function(gamename) {
C . Console16bit = Object.create(GameConsole.prototype).load = function (gamename) {
D . Console16bit.prototype.load(gamename) {

A

B

217
Q

Which three statements are true about promises?
Choose 3 answers

A . The executor of a new Promise runs automatically.
B . A Promise has a .then() method.
C . A fulfilled or rejected promise will not change states.
D . A settled promise can become resolved.
E . A pending promise can become fulfilled, settled, or rejected.

A

B,C,E

218
Q

A developer is working on an ecommerce website where the delivery date is dynamically calculated based on the current day. The code line below is responsible for this calculation.

Const deliveryDate = new Date ();
Due to changes in the business requirements, the delivery date must now be today’s
date + 9 days.

Which code meets this new requirement?

A . deliveryDate.setDate(( new Date ( )).getDate () +9);
B . deliveryDate.setDate( Date.current () + 9);
C . deliveryDate.date = new Date(+9) ;
D . deliveryDate.date = Date.current () + 9;

A

A

219
Q

Refer to the code below:
for(let number =2 ; number <= 5 ; number += 1 ) {
// insert code statement here
}

The developer needs to insert a code statement in the location shown. The code statement has these requirements:

  1. Does require an import
  2. Logs an error when the boolean statement evaluates to false
  3. Works in both the browser and Node.js

Which meet the requirements?

A . assert (number % 2 === 0);
B . console.error(number % 2 === 0);
C . console.debug(number % 2 === 0);
D . console.assert(number % 2 === 0);

A

B

220
Q

Refer to the code below:
01 let car1 = new promise((_, reject) =>
02 setTimeout(reject, 2000, ‘‘Car 1 crashed in’’));
03 let car2 = new Promise(resolve => setTimeout(resolve, 1500, ‘‘Car 2
completed’’));
04 let car3 = new Promise(resolve => setTimeout (resolve, 3000, ‘‘Car 3
Completed’’));
05 Promise.race([car1, car2, car3])
06 .then(value => (
07 let result = $(value) the race. `;
08 ))
09 .catch( arr => (
10 console.log(‘‘Race is cancelled.’’, err);
11 ));

What is the value of result when Promise.race executes?

A . Car 3 completed the race.
B . Car 1 crashed in the race.
C . Car 2 completed the race.
D . Race is cancelled.

A

C

221
Q

Which statement phrases successfully?

A . JSON.parse ( ‘ foo ‘ );
B . JSON.parse ( ‘’ foo ‘’ );
C . JSON.parse( ‘’ ‘ foo ‘ ‘’ );
D . JSON.parse(‘ ‘’ foo ‘’ ‘);

A

D

222
Q

Refer to the code below:

01 const exec = (item, delay) =>{
02 new Promise(resolve => setTimeout( () => resolve(item), delay)),
03 async function runParallel() {
04 Const (result1, result2, result3) = await Promise.all{
05 [exec (‘x’, ‘100’) , exec(‘y’, 500), exec(‘z’, ‘100’)]
06 );07 return parallel is done: $(result1) $(result2)$(result3);
08 }}}

Which two statements correctly execute the runParallel () function?

Choose 2 answers

A . Async runParallel () .then(data);
B . runParallel ( ). done(function(data){
return data;});
C . runParallel () .then(data);
D . runParallel () .then(function(data)
return data

A

B,D

223
Q

A developer needs to test this function:
01 const sum3 = (arr) => (
02 if (!arr.length) return 0,
03 if (arr.length === 1) return arr[0],
04 if (arr.length === 2) return arr[0] + arr[1],
05 return arr[0] + arr[1] + arr[2],
06 );

Which two assert statements are valid tests for the function?

Choose 2 answers

A . console.assert(sum3(1, ‘2’)) == 12);
B . console.assert(sum3(0)) == 0);
C . console.assert(sum3(-3, 2 )) == -1);
D . console.assert(sum3(‘hello’, 2, 3, 4)) === NaN);

A

A,C