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
03 alert( ' Hey! I am John Doe ' );
04
05 }
06 button.addEventListener( ' click ' , listen);
Which two code lines make this code work as required?
A 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?
Which three browser specific APIs are available for developers to persist data between page loads?
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?
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 developer copied a JavaScript object:
01 function Person() {
02 this.firstName = " John " ;
03 this.lastName = " Doe " ;
04 this.name = () = > `${this.firstName},${this.lastName}`;
05 }
06
07 const john = new Person();
08 const dan = Object.assign({}, john);
09 dan.firstName = ' Dan ' ;
How does the developer access dan ' s firstName, lastName?
Refer to the code below:
01 async function functionUnderTest(isOK) {
02 if (isOK) return ' OK ' ;
03 throw new Error( ' not OK ' );
04 }
Which assertion accurately tests the above code?
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?
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 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?