Summer Sale Special - Limited Time 70% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: sntaclus

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 msg is declared and assigned a value on line 03.

function getAvailabilityMessage(item) {

if (getAvailability(item)) {

var msg = " Username available " ;

return msg;

}

}

A.

" msg is not defined "

B.

" newUserName "

C.

" Username available "

D.

undefined

A developer creates a new web server that uses Node.js. It imports a server library that uses events and callbacks for handling server functionality. The server library is imported with require and is made available to the code by a variable named server. The developer wants to log any issues that the server has while booting up.

Which code logs an error at boot time with an event?

A.

server.error((error) = > {

console.log( ' ERROR ' , error);

});

B.

server.catch((error) = > {

console.log( ' ERROR ' , error);

});

C.

try {

server.start();

} catch(error) {

console.log( ' ERROR ' , error);

}

D.

server.on( ' error ' , (error) = > {

console.log( ' ERROR ' , error);

});

Refer to the code:

01 console.log( ' Start ' );

02 Promise.resolve( ' Success ' ).then(function(value) {

03 console.log( ' Success ' );

04 });

05 console.log( ' End ' );

What is the output after the code executes successfully?

A.

Start

Success

End

B.

Start

End

Success

C.

End

Start

Success

D.

Success

Start

End

A developer wants to create a simple image upload using the File API.

HTML:

< input type= " file " onchange= " previewFile() " >

< img src= " " height= " 200 " alt= " Image preview... " / >

JavaScript:

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 }

Which code in lines 04 and 08 allows the selected local image to be displayed?

A.

04 const reader = new File();

08 if (file) reader.readAsDataURL(file);

B.

04 const reader = new FileReader();

08 if (file) reader.readAsDataURL(file);

C.

04 const reader = new FileReader();

08 if (file) URL.createObjectURL(file);

A class was written to represent regular items and sale items. Code:

01 let regItem = new Item( ' Scarf ' , 55);

02 let saleItem = new SaleItem( ' Shirt ' , 80, .1);

03 Item.prototype.description = function() { return ' This is a ' + this.name; }

04 console.log(regItem.description());

05 console.log(saleItem.description());

06

07 SaleItem.prototype.description = function() { return ' This is a discounted ' + this.name; }

08 console.log(regItem.description());

09 console.log(saleItem.description());

What is the output?

A.

This is a Scarf

Uncaught TypeError: saleItem.description is not a function

This is a Shirt

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

Uncaught TypeError: saleItem.description is not a function

This is a Scarf

This is a discounted Shirt

D.

This is a Scarf

This is a Shirt

This is a discounted Scarf

This is a discounted Shirt

Given the code below:

01 setTimeout(() = > {

02 console.log(1);

03 }, 1100);

04 console.log(2);

05 new Promise((resolve, reject) = > {

06 setTimeout(() = > {

07 reject(console.log(3));

08 }, 1000);

09 }).catch(() = > {

10 console.log(4);

11 });

12 console.log(5);

What is logged to the console?

A.

25341

B.

12435

C.

12534

D.

21435

01 function changeValue(obj) {

02 obj.value = obj.value / 2;

03 }

04 const objA = {value: 10};

05 const objB = objA;

06

07 changeValue(objB);

08 const result = objA.value;

What is the value of result after the code executes?

A.

low

B.

10

C.

5

D.

undefined

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

A.

String(var1).concat(var2)

B.

String.concat(var1 + var2)

C.

var1 + var2

D.

var1.toString() + var2.toString()

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.

__filename

B.

window.location

C.

this.path

D.

__dirname

Refer to the code below:

let productSKU = ' 8675309 ' ;

A developer has a requirement to generate SKU numbers that are always 19 characters long, starting with ' sku ' , and padded with zeros.

Which statement assigns the value sku000000008675309?

A.

productSKU = productSKU.padEnd(16, ' 0 ' ).padStart( ' sku ' );

B.

productSKU = productSKU.padStart(16, ' 0 ' ).padStart(19, ' sku ' );

C.

productSKU = productSKU.padEnd(16, ' 0 ' ).padStart(19, ' sku ' );

D.

productSKU = productSKU.padStart(19, ' 0 ' ).padStart( ' sku ' );