A test searches for:
< button class= " blue " > Checkout < /button >
But the actual HTML is:
< button > Checkout < /button >
The test fails because it expects a class that no longer exists.
What type of test outcome is this?
Refer to the following code:
01 let obj = {
02 foo: 1,
03 bar: 2
04 }
05 let output = []
06
07 for (let something of obj) {
08 output.push(something);
09 }
10
11 console.log(output);
What is the value of output on line 11?
Given the code below:
01 const delay = async delay = > {
02 return new Promise((resolve, reject) = > {
03 console.log(1);
04 setTimeout(resolve, delay);
05 });
06 };
07
08 const callDelay = async () = > {
09 console.log(2);
10 const yup = await delay(1000);
11 console.log(3);
12 };
13
14 console.log(4);
15 callDelay();
16 console.log(5);
What is logged to the console?
Which statement allows a developer to update the browser navigation history without a page refresh?
Considering type coercion, what does the following expression evaluate to?
true + ' 13 ' + NaN
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;
}
}
for (let number = 2; number < = 5; number += 1) {
// faster code statement here
}
Which statement meets the requirements to log an error when the Boolean statement evaluates to false?
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?
(With corrected typing errors: node_inspect → node inspect, node_start_inspect → node start inspect.)
Corrected code:
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 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. The test passes:
01 let res = sum3([1, 2, 3]);
02 console.assert(res === 6);
03
04 res = sum3([1, 2, 3, 4]);
05 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.
Which two results occur when running the test on the updated sum3 function?
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?
Given the code:
const copy = JSON.stringify([new String( ' false ' ), new Boolean(false), undefined]);
What is the value of copy?
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 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?
Refer to the code snippet:
01 function getAvailableilityMessage(item) {
02 if (getAvailableility(item)) {
03 var msg = " Username available " ;
04 }
05 return msg;
06 }
What is the return value of msg when getAvailableilityMessage( " newUserName " ) is executed and getAvailableility( " newUserName " ) returns false?
Refer to the code:
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?
Refer to the code below:
01 let timedFunction = () = > {
02 console.log( ' Timer called. ' );
03 };
04
05 let timerId = setInterval(timedFunction, 1000);
Which statement allows a developer to cancel the scheduled timed function?
Refer to the code below:
01 new Promise((resolve, reject) = > {
02 const fraction = Math.random();
03 if (fraction > 0.5) reject( ' fraction > 0.5, ' + fraction);
04 resolve(fraction);
05 })
06 .then(() = > console.log( ' resolved ' ))
07 .catch((error) = > console.error(error))
08 .finally(() = > console.log( ' when am I called? ' ));
When does Promise.finally on line 08 get called?
01 function Animal(size, type) {
02 this.type = type || ' Animal ' ;
03 this.canTalk = false;
04 }
05
06 Animal.prototype.speak = function() {
07 if (this.canTalk) {
08 console.log( " It spoke! " );
09 }
10 };
11
12 let Pet = function(size, type, name, owner) {
13 Animal.call(this, size, type);
14 this.size = size;
15 this.name = name;
16 this.owner = owner;
17 }
18
19 Pet.prototype = Object.create(Animal.prototype);
20 let pet1 = new Pet();
Given the code above, which three properties are set for pet1?
A developer imports:
import printPrice from ' /path/PricePrettyPrint.js ' ;
What must be true about printPrice for this import to work?
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 developer wants to use a module called DatePrettyPrint.
This module exports one default function called printDate().
How can the developer import and use printDate()?
After user acceptance testing, the developer is asked to change the webpage background based on the user’s location. It works on the developer’s computer but not on the tester’s machine.
Which two actions will help determine accurate results?
Refer to the code below (assuming Promise.race is intended):
let cat3 = new Promise(resolve = >
setTimeout(resolve, 3000, " Cat 3 completes " )
);
Promise.race([cat1, cat2, cat3])
.then(value = > {
let result = `${value} the race.`;
})
.catch(err = > {
console.log( " Race is cancelled: " , err);
});
(Assuming cat1 and cat2 are similar to earlier examples: cat2 resolves fastest.)
What is the value of result when Promise.race executes?
Function to test:
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 this function?
Refer to the following object:
const dog = {
firstName: ' Beau ' ,
lastName: ' Boo ' ,
get fullName() {
return this.firstName + ' ' + this.lastName;
}
};
How can a developer access the fullName property for dog?
Given the following code:
01 let x = null;
02 console.log(typeof x);
What is the output of line 02?
Given the JavaScript below:
01 function filterDOM(searchString){
02 const parsedSearchString = searchString & & searchString.toLowerCase();
03 document.querySelectorAll( ' .account ' ).forEach(account = > {
04 const accountName = account.innerHTML.toLowerCase();
05 account.style.display = accountName.includes(parsedSearchString) ? /* Insert code here */;
06 });
07 }
Which code should replace the placeholder comment on line 05 to hide accounts that do not match the search string?
Refer to the code below:
01 function changeValue(param) {
02 param = 5;
03 }
04 let a = 10;
05 let b = a;
06
07 changeValue(b);
08 const result = a + ' - ' + b;
What is the value of result when the code executes?
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
05 };
Which two options access the email attribute in the object?
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?
Which actions can be done using the JavaScript browser console?
Which statement accurately describes an aspect of promises?
Given the JavaScript below:
function onLoad() {
console.log( " Page has loaded! " );
}
Where can the developer see the log statement after loading the page in the browser?
Given the HTML below:
< div >
< div id= " row-uc " > Universal 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 page loads 50+ < div class= " ad-library-item " > elements, all ads.
Developer wants to quickly and temporarily remove them.
Options:
A team at Universal Containers works on a big project and uses Yarn to deal with the project’s dependencies. A developer added a dependency to manipulate dates and pushed the updates to the remote repository. The rest of the team complains that the dependency does not get downloaded when they execute yarn.
What could be the reason for this?
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 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?
Refer to the following object:
01 const cat = {
02 firstName: ' Fancy ' ,
03 lastName: ' Whiskers ' ,
04 get fullName(){
05 return this.firstName + ' ' + this.lastName;
06 }
07 };
How can a developer access the fullName property for cat?
Given a value, which two options can a developer use to detect if the value is NaN?
Given a value, which three options can a developer use to detect if the value is NaN?
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?
Which two implementations of utils.js support foo and bar?