Winter Sale Special 65% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: ex2p65

Exact2Pass Menu

Question # 4

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*/, ‘’);

Full Access
Question # 5

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

Full Access
Question # 6

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 {

Full Access
Question # 7

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)

Full Access
Question # 8

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;

Full Access
Question # 9

Refer to following code block:

Let array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,];

Let output =0;

For (let num of array){

if (output >0){

Break;

}

if(num % 2 == 0){

Continue;

}

Output +=num;

What is the value of output after the code executes?

A.

16

B.

36

C.

11

D.

25

Full Access
Question # 10

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.

Full Access
Question # 11

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

Full Access
Question # 12

Refer to the code below:

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

Full Access
Question # 13

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

Full Access
Question # 14

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

Full Access
Question # 15

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

Full Access
Question # 16

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

Full Access
Question # 17

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.

Full Access
Question # 18

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

Full Access
Question # 19

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

Full Access
Question # 20

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

Full Access
Question # 21

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]

Full Access
Question # 22

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

Full Access
Question # 23

Refer to the following code block:

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.

Full Access
Question # 24

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.

Full Access
Question # 25

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

Full Access
Question # 26

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

};

Full Access
Question # 27

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

Full Access
Question # 28

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”

Full Access
Question # 29

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.

Full Access
Question # 30

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

Full Access
Question # 31

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

Full Access
Question # 32

Which option is a core Node,js module?

A.

Path

B.

Ios

C.

Memory

D.

locate

Full Access
Question # 33

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

Full Access