Quiz
JD1
Create a free account to finish this quiz
Save your progress and see your final score.
Already have an account? Sign in
Questions in this quiz (159)
1Given 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.- ABoolean(var1 && var2)
- Bvar1 && var2
- Cvar1.toBoolean() && var2.toBoolean()
- DBoolean(var1) && Boolean(var2)
2Which option is true about the strict mode in imported modules?
- AAdd the statement use non-strict; before any other statements in the module to enable not-strict mode
- BA developer can only reference notStrict() functions from the imported module
- CImported modules are in strict mode whether you declare them as such or not
- DAdd the statement use strict = false; before any other statements in the module to enable not-strict mode
3A 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?- ATrue positive
- BTrue negative
- CFalse positive
- DFalse negative
4Refer to the code below:
let textValue = '1984';
Which code assignment shows a correct way to convert this string to an integer?- Alet numberValue = Integer(textValue);
- Blet numberValue = textValue.toInteger();
- Clet numberValue = (Number) textValue;
- Dlet numberValue = Number(textValue);
5Refer to the code below:
Const p1 = 3.1415926;
What is the data type of p1?- ADouble
- BNumber
- CFloat
- DDecimal
6Which two console logs output NaN?
Choose 2 answers.- Aconsole.log(10/0);
- Bconsole.log(10/'five');
- Cconsole.log(10/Number('5'));
- Dconsole.log(parseInt('two'));
7A 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 atency peroid?- ADEBUG = http, https node server.js
- BNODE_DEBUG = http, http node server.js
- CDEBUG = true node server.js
- DNODE_DEBUG = true node server.js
8A 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?- AsetTimeout(formatName, 5000, 'John', 'Doe')'
- BsetTimeout('formatName',5000, 'John', 'Doe')'
- CsetTimeout(formatName('John', 'Doe'), 5000)'
- DsetTimeout(() = > (formatName('John', 'Doe')), 5000);
9Given the JavaScript below:
function filterDOM(searchString) {
const parsedSearchString = searchString && searchString.toLowerCase();
document.querySelectorAll('.account').forEach(account => (
const accountName = account.innerHTML.toLowerCase();
account.style.display = accountName.includes(parsedSearchString) ? /insert code here/;
});
}
Which code should replace the placeholder comment on line 05 to hide accounts that do not match the search string?- A'hidden' : 'visible'
- B'none' : 'block'
- C'block' : 'none'
- D'visible' : 'hidden'
10Given 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 the page is clicked?- AEvent.clicked
- Be.nodeTarget == this
- Cevent.target.nodeName == 'BUTTON'
- Dbutton.addEventListener('click');
11Given the code below:
const copy = JSON.stringify([new String('false'), new Boolean(false), undefined]);
What is the value of copy?- A"[false, {}]"
- B"["false", false, undefined]"
- C"["false", false, null]"
- D"["false", {}]"
12A 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?- ATerminal running the web server
- BBrowser performance tools
- CBrowser JavaScript console
- DOn the webpage
13Refer to the code below:
const exec = (item, delay) =>
new Promise(resolve => setTimeout( ()=> resolve(item), delay));
async function runParallel() {
const (result1, result2, result3) = await Promise.all(
[exec('x', '100'), exec('y', 500), exec('z','100')]
);
return 'parallel is done: $(result1)$(result2)$(result3)';
}
Which two statements correctly execute the runParallel() function?
Choose 2 answers.- Aasync runParallel().then(data);
- BrunParallel().done(function(data){
return data;
}); - CrunParallel().then(data);
- DrunParallel().then(function(data) {
return data;
});
14Refer 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 the result when Promise.race executes?- ACar 3 completed the race.
- BCar 2 completed the race.
- CCar 1 crashed in the race.
- DRace is cancelled.
15Which code statement below correctly persists an object in local Storage?
- Aconst setLocalStorage = (storageKey, jsObject) => {
window.localStorage.setItem(storageKey, JSON,stringify(jsObject));
} - Bconst setLocalStorage = (jsObject) => {
window.localStorage.connectObject(jsObject));
} - Cconst setLocalStorage = (jsObject) => {
window.localStorage.setItem(jsObject);
} - Dconst setLocalStorage = (storageKey, jsObject) => {
window.localStorage.persist(storageKey, jsObject);
}
- Aconst setLocalStorage = (storageKey, jsObject) => {
16Refer 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?- AWhen rejected
- BWhen resolved and settled
- CWhen resolved
- DWhen resolved or rejected
17Given the following code:
let x = null;
console.log(typeof x);
What is the output of line 02?- A"null"
- B"Object"
- C"Undefined"
- D"x"
18Which option is a core Node.js module?
- Apath
- Bios
- Cmemory
- Dlocale
19A developer wants to define a function log to be used a few times on a single-file JavaScript script.
// Line 1 replacement
console.log('LOG:', logInput);
}
Which two options can correctly replace line 01 and declare the function for use?- Afunction log(logInput) {
- Bconst log(logInput) {
- Cconst log = (logInput) =>
- Dfunction log = (logInput) {
20A 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?- Aimport * from '/path/universalContainersLib.js';
universalContainersLib.foo();
universalContainersLib.bar(); - Bimport {foo, bar} from '/path/universalContainersLib.js';
foo();
bar(); - Cimport all from '/path/universalContainersLib.js';
universalContainersLib.foo();
universalContainersLib.bar(); - Dimport * as lib from '/path/universalContianersLib.js';
lib.foo();
lib.bar();
- Aimport * from '/path/universalContainersLib.js';
21Refer 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?- AStart
Success
End - BEnd
Start
Success - CStart
End
Success - DSuccess
Start
End
- AStart
22Refer to the code below:
let timedFunction = () => {
console.log('Timer called.);
}
let timerId = setTimeout(timedFunction, 1000);
Which statement allows a developer to cancel the scheduled timed function?- AremoveTimeout(timedFunction);
- BremoveTimeout(timerId);
- CclearTimeout(timerId);
- DclearTimeout(timerFunction);
23Refer to the code below:
let foodMenu = ['Pizza', 'Burger', 'French fries'];
let finalMenu = foodMenu;
finalMenu.push('Garlic bread');
What is the value of foodMenu after the code executes?- A['Pizza', 'Burger', 'French fries', 'Garlic bread']
- B['Pizza', 'Burger', 'French fries']
- C['Garlic bread', 'Pizza', 'Burger', 'French fries']
- D['Garlic bread']
24Refer 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 sku0000000000008675309?- AproductSKU = productSKU.padEnd(16, '0').padStart(19, 'sku');
- BproductSKU = productSKU.padEnd(16, '0').padStart('sku');
- CproductSKU = productSKU.padStart(16, '0').padStart(19, 'sku');
- DproductSKU = productSKU.padStart(19, '0').padStart('sku');
25A 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?- Atry {
setTimeout(function() {
countSheep();
}, 1000);
} catch (e) {
handleError(e);
} - Btry {
countSheep();
} finally {
handleError(e);
} - CsetTimeout(function() {
try {
countSheep();
} catch(e) {
handleError(e);
}
}, 1000); - Dtry {
countSheep();
} handleError (e) {
catch(e)
}
- Atry {
26Which statement accurately describes an aspect of promises?
- A.then() manipulates and returns the original promise
- BArguments for the callback function passed to .then() are optional
- C.then() cannot be added after a catch
- DIn a .then() function, returning results is not necessary since callbacks will catch the result of a previous promise
27Refer to the following code:
Which statement should be added to line 09 for the code to display 'The truck 123AB has a weight of 5000 lb'?
- Asuper(plate);
- Bsuper.plate = plate;
- CVehice.plate = plate;
- Dthis.plate = plate
28Considering type coercion, what does the following expression evaluate to?
true + '13' + NaN- A'true13NaN'
- B'true13'
- C14
- D'113NaN'
29Which statement parses successfully?
- AJSON.parse(' "foo" ');
- BJSON.parse(" 'foo' ");
- CJSON.parse('foo');
- DJSON.parse("foo");
30Refer to the code below:
What are the values for first and second once the code executes?
- Afirst is Why and second is Where
- Bfirst is Who and second is When
- Cfirst is Why and second is When
- Dfirst is Who ad second is Where
31A 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?- A1.1.4
- B1.2.0
- C1.2.3
- D2.0.0
32Refer to the code below:
Which code change should be made for the console to log only Row log when 'Click me!' is clicked?
- AAdd event.removeEventListener(); to printMessage function
- BAdd event.removeEventListener(); to window.onLoad event handler
- CAdd event.stopPropagation(); to window.onLoad event handler
- DAdd event.stopPropagation(); to printMessage function
33A developer wants to create a simple image upload in the browser using the File API. The HTML is below:
The JavaScript portion is:
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?
- A04 const reader = new File();
08 if (file) reader.readAsDataURL(file); - B04 const reader = new FileReader();
08 if(file) URL.createObjectURL(file); - C04 const reader = new File();
08 if (file) URL.createObjectURL(file); - D04 const reader = new FileReader();
08 if (file) reader.readAsDataURL(file);
- A04 const reader = new File();
34Refer to the code below:
When does Promise.finally on line 08 get called?
- AWhen resolved or rejected
- BWhen resolved and settled
- CWhen resolved
- DWhen rejected
35Cloud Kicks has a class to represent items for sale in an online store, as shown below:
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 property declares the ClothingItem class such that it inherits from Item?- Aclass ClothingItem extends Item {
- Bclass ClothingItem implements Item {
- Cclass ClothingItem super Item {
- Dclass ClothingItem {
36Refer to the code below:
A developer needs to dispatch a custom event called update to send information about recordId.
Which two operations could a developer insert at the placeholder in line 02 to achieve this?
Choose 2 answers.
- A'update', '123abc'
- B'update', {
detail : {
recordId : '123abc'
}
} - C'update', {
recordId : '123abc'
} - D{type : 'update', recordId : '123abc'}
37Given the code below:
What happens when the code executes?
- AThe url variable has a global scope and line 02 throws an error
- BThe url variable has local scope and line 02 throws an error
- CThe url variable has local scope and line 02 executes correctly
- DThe url variable has a global scope and line 02 executes correctly
38Refer to the HTML below:
Which expression outputs the screen width of the element with the ID card-01?
- Adocument.getElementById('card01').innerHTML.length*6
- Bdocument.getelementById('card-01').getBoundingClientRect().width
- Cdocument.getelementById('card-01').width
- Ddocument.getElementById('card-01').style.width
39Universal Containers (UC) just launched a new landing page, but users complain that the website is slow. A developer found some functions 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.
Which function can the developer use to obtain the time spent by every one of the three functions?
- Aconsole.timeLog()
- Bconsole.timeStamp()
- Cconsole.trace()
- Dconsole.getTime()
40Refer to the code below:
The developer needs to insert a code statement in the location shown. The code statement has these requirements:
1. Does not require an import
2. Logs an error when the Boolean statement evaluates to false
3. Works in both the browser and Node.js
Which statement meets these requirements?
- Aconsole.assert(number % 2 === 0);
- Bassert(number % 2 === 0);
- Cconsole.error(number % 2 === 0);
- Dconsole.debug(number % 2 === 0);
41A 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 tet passes.
A different developer made changes to the behaviour of sum3 to instead sum only the first two numbers present in the array.
Which two results occur when running this test on the uploaded sum3 function?
Choose 2 answers.
- AThe line 05 assertion passes
- BThe line 02 assertion passes
- CThe line 02 assertion fails
- DThe line 05 assertion fails
42A 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?- Aconst server = require('secure-server');
- Bconst http = require('http');
- Cconst tls = require('tls');
- Dconst https = require('https');
43A developer creates a class that represents a blog post based on the requirements that a Post should have a body, author and view count.
The code is shown below:
Which statement should be inserted in the placeholder on line 02 to allow for a variable to be set to a new instance of a Post with the three attributes correctly populated?
- Aconstructor(body, author, viewCount) {
- Bconstructor() {
- Csuper(body, author, viewCount) {
- Dfunction Post(body, author, viewCount) {
44Universal 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:
All the elements include the same ad-library-item class. They are hidden by default and they are randomly displayed while the user navigates through the page.
Tired of all the ads, what can the developer do to temporarily and quickly remove them?
- AUse the DOM inspector to prevent the load event to be fired
- BUse the browser console to execute a script that removes all the elements containing the class ad-library-item
- CUse the browser console to execute a script that prevents the load event to be fired
- DUse the DOM inspector to remove all the elements containing the class ad-library-item
45Refer to the code snippet below:
What is the value of array after the code executes?
- A[1,2,3,4,5,4,4]
- B[1,2,3,5]
- C[1,2,3,4,4,5,4]
- D[1,2,3,4,5,4]
46Refer to the code below:
What is the value of result when the code executes?
- A10-10
- B5-5
- C10-5
- D5-10
47Refer to the code:
Given the code above, which three properties are set for pet1?
- Aspeak
- Bowner
- Ctype
- Dname
- EcanTalk
48Given the code below:
What is logged to the console?
- A2 5 1 3 4
- B2 1 4 3 5
- C1 2 5 3 4
- D1 2 4 3 5
49Refer to the code below:
What is the output after the code executes?
- AReferenceError: eyeColor is not defined
- BReferenceError: assignment to undeclared variable "Person"
- Cundefined
- DDeveloper
50A 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?- A1 growl method is created regardless of which option is used
- B1000 growl methods are created regardless of which option is used
- C1000 growl methods are created for Option A. 1 growl method is created for Option B
- D1 growl method is created for Option A. 1000 growl methods are created for Option B
51A developer is asked to fix some bugs reported by users. To do that, the developer adds a breakpoint for debugging.
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:
- AThe values of the carSpeed and fourWheels variables
- BThe style, event listeners and other attributes applied to the carSpeed DOM element
- CA variable displaying the number of instances created for the Car object
- DThe information stored in the window.localStorage property
52Refer to the following code block:
What is the value of output after the code executes?
- A11
- B36
- C25
- D16
53A 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 boot time with an event?- A.

- B;

- C,

- D'

- A.
54What are two unique features of functions defined with a fat arrow as compared to normal function definition?
Choose 2 answers:- AThe function generates its own this making it useful for separating the function's scope from its enclosing scope
- BThe function receives an argument that is always in scope, called parentThis, which is the enclosing lexical scope
- CIf the function has a single expression in the function body, the expression will be evaluated and implicitly returned
- DThe function uses the this from the enclosing scope
55A developer uses the code below to format a date.
After executing, what is the value of formattedDate?
- AMay 10, 2020
- BJune 10, 2020
- COctober 05, 2020
- DNovember 05, 2020
56Refer to the code snippet:
A developer writes this code 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.
What is the return value of msg when getAvailabilityMessage("newUserName") is executed and getAvailability("newUserName") returns false?
- Aundefined
- B"msg is not defined"
- C"Username available"
- D"newUserName"
57Refer to the code below:
What are the values of objBook and newObjBook respectively?
- A{ author: "Robert", title: "Javascript" }
- B{ author: "Robert", title: "Javascript" }
{ author: "Robert", title: "Javascript" } - C{ author: "Robert" }
{ author: "Robert", title: "Javascript" } - D{ title: "JavaScript" }
{ title: "JavaScript" }
58Refer to the string below:
const str = 'Salesforce'
Which two statements result in the word 'Sales'?
Choose 2 answers.- Astr.substr(1, 5);
- Bstr.substr(0, 5);
- Cstr.substring(1, 5);
- Dstr.substring(0, 5);
59bar.awesome is popular JavaScript module. The versions published 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.
A developer runs this command: npm install
Which version of bar.awesome is installed?
- A1.3.5
- B1.4.0
- C1.3.1
- DThe command fails because version 1.3.0 is not found
60Refer to the code below:
After running this code, which result is displayed on the console?
- A5
undefined - B5
-1 - C3
0 - Dtrue
false
- A5
61Given a value, which two options can a developer use to detect if the value is NaN?
Choose 2 answers.- AisNaN(value)
- BObject.is(value, NaN)
- Cvalue == NaN
- Dvalue === Number.NaN
62A developer implements and calls the following code when an application state change occurs:
If the back button is clicked after this method is executed, what can a developer expect?
- AA popstate event is fired with a state property that details the application's last state
- BA navigate event is fired with a state property that details the previous application state
- CThe page is navigated away from and the previous page in the browser's history is loaded
- DThe page reloads and all JavaScript is reinitialized
63A 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:
There is a new requirement for a developer to implement a description method that will return a brief description for Item and SaleItem.
What is the output when executing the code above?
- AThis is a Scarf
Uncaught TypeError: salesItem.description is not a function
This is a Shirt
This is a discounted Shirt - BThis is a Scarf
this is a Shirt
This is a discounted Scarf
This is a discounted Shirt - CThis is a Scarf
This is a Shirt
This is a Scarf
This is a discounted Shirt - DThis is a Scarf
Uncaught TypeError: salesItem.description is not a function
This is a Scarf
This is a discounted Shirt
- AThis is a Scarf
64Refer to the code below:
What is the value of the result after line 10 executes?
- AError: myFather.job is not a function
- BJohn Developer
- Cundefined Developer
- DJohn undefined
65A developer is creating a simple webpage with a button. When a user clicks this button for the first time, a message is displayed.
A 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.
Which two code lines make this code work as required?
Choose 2 answers.
- AOn line 04, use event.stopPropagation()
- BOn line 02, use event.first to test if it is the first execution
- COn line 04, use button.removeEventListener('click', listen);
- DOn line 06, add an option called once to button.addEventListener()
66Refer to the HTML below:
<p> The current status of an Order: <span id="status">In Progress</span></p>
Which JavaScript statement changes the text "In Progress" to "Completed"?- Adocument.getElementById("status").Value = 'Completed';
- Bdocument.getElementById(".status").innerHTML = 'Completed';
- Cdocument.getElementById("status").innerHTML = 'Completed';
- Ddocument.getElementById("#status").innerHTML = 'Completed';
67A developer implements a function that adds a few values.
Which three options can the developer invoke for this function to get a return value of 10?
- Asum()(10)
- Bsum(10)()
- Csum(5,5)()
- Dsum()(5,5)
- Esum(5)(5)
68A developer writes the code below to calculate the factorial of a given number.
What is the result of executing line 04?
- A0
- B6
- CRuntimeError
- DInfinity
69A developer has an ErrorHandler module that contains multiple functions.
What kind of export should be leveraged so that multiple functions can be used?- Anamed
- Ball
- Cmulti
- DDefault
70A Universal Containers, every team has its own way of copying JavaScript objects. The code snippet shows an implementation from one team:
What is the output of the code execution?
- ATypeError: Assignment to constant variable
- BHello Dan Doe
- CHello John Doe
- DTypeError: dan.name is not a function
71What statement can a developer apply to increment the browser's navigaton history without a page refresh?
- Awindow.history.pushState(newStateObject);
- Bwindow.history.pushState(newStateObject, '', null);
- Cwindow.history.replaceState(newStateObject, '', null);
- Dwindow.history.state.push(newStateObject);
72Given the code below:
What is logged to the console?
- A1 2 3
- B1 3 2
- C2 1 3
- D2 3 1
73Refer to the following object:
How can a developer access the fullName property for cat?
- Acat.get.fullName
- Bcat.fullName()
- Ccat.function.fullName()
- Dcat.fullName
74Refer to the code below:
What is displayed when the code executes?
- Aa
- Bundefined
- Cnull
- DReferenceError: b is not defined
75Given the code below:
Which method can be used to provide a visual representaton of the list of users and to allow sorting by the name or email attribute?
- Aconsole.group(usersList)
- Bconsole.table(usersList);
- Cconsole.info(usersList);
- Dconsole.groupCollapsed(usersList);
76Refer to the code below:
Considering the implications of 'use strict' on line 04, which three statements describe the execution of the code?
Choose 3 answers.
- Az is equal to 3.14
- B'use strict' is hoisted, so it has an effect on all lines
- CLine 05 throws an error
- D'use strict' has an effect between line 04 and the end of the file
- E'use strict' has an effect only on line 05
77Refer to the following code:
What will the console show when the button is clicked?
- AOuter message
Inner message - BInner message
Outer message - COuter message
- DInner message
- AOuter message
78Which JavaScript methods can be used to serialize an object into a string and deseralize a JSON string into an object respectively?
- AJSON.encode and JSON.decode
- BJSON.serialize and JSON.deserialize
- CJSON.stringify and JSON.parse
- DJSON.parse and JSON.deserialize
79A developer creates a generic function to log custom messages in the console. To do this, the function below is implemented.
Which three console logging methods alow the use of string substitution in line 02?
Choose 3 answers.
- Aassert
- Bmessage
- Cinfo
- Derror
- Elog
80A developer needs to test this function:
Which two assert statements are valid tests for this functions?
Choose 2 answers.
- Aconsole.assert(sum3([0]) === 0);
- Bconsole.assert(sum3([-3, 2]) === -1);
- Cconsole.assert({sum3([1,'2']) == 12);
- Dconsole.assert(sum3(['hello', 2, 3, 4]) === NaN);
81Refer to the code below:
What value can a developer expect when referencing o.js.secondCity?
- Aundefined
- B'new york'
- C'New York'
- DAn error
82myArray can have one level, two levels or more levels.
Which statement flattens myArray when it can be arbitrarily nested?- AmyArray.reduce((prev, curr) => prev.concat(curr), []);
- BmyArray.join(",").split(",");
- C[].concat(...myArray);
- DmyArray.flat(Infinity);
83Refer to the following code:
What is the output of line 11?
- A["foo", "bar"]
- B[1, 2]
- C["foo:1", "bar:2"]
- D["bar", "foo"]
84Refer to the code below:
What is the output of this function when called with an empty array?
- AReturns 10
- BReturns NaN
- CReturns 0
- DThrows an error
85Refer to the code below:
Which code executes sayHello once, two minutes from now?
- AsetInterval(sayHello, 120000);
- Bdelay(sayHello, 120000);
- CsetTimeout(sayHello, 120000);
- DsetTimeout(sayHello(), 120000);
86Given the HTML below:
Which statement adds the priority-account CSS class to the Universal Containers row?
- Adocument.querySelector('#row-uc').classList.add('priority-account');
- Bdocument.querySelector('#row-uc').classes.push('priority-account');
- Cdocument.getElementById('row-uc').addClass('priority-account');
- Ddocument.querySelectorAll('#row-uc').classList.add('priority-account');
87A 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:
The developer wrote the JavaScript code below:
When the user clicks the button, the output is always "Hello".
What needs to be done to make this code work as expected?
- AReplace line 02 with button.addEventListener("onclick", function() {
- BReplace line 04 with console.log(input.value);
- CReplace line 02 with button.addCallback("click", function() {
- DReplace line 03 with const input = document.getElementByNme('input');
88Refer to the code below:
Which value can a developer expect when referencing country .capital.cityString?
- Aundefined
- BAn error
- C'London'
- D'NaN'
89Which two options are core Node.js modules?
Choose 2 answers- Aexception
- Biostream
- Chttp
- Dworker
90Refer to the following code block:
What is the console output?
- AJackie got 70% on test.
- BBetter student Jackie got 100% on test.
- CBetter Student Jackie got 70% on test.
- DUncaught ReferenceError
91A 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 2 answers.- Alet res = fizzbuzz(5);
console.assert(res === ''); - Blet res = fizzbuzz(15);
console.assert(res === 'fizzbuzz'); - Clet res = fizzbuzz(Infinity);
console.assert(res === ''); - Dlet res = fizzbuzz(3);
console.assert(res === 'buzz');
- Alet res = fizzbuzz(5);
92Given the code block below:
What should a developer insert at line 15 to output the following message using the load method?
SNEGeneziz is loading a cartidge game: Super Monic 3x Force...
- AConsole16bit.prototype.load(gamename) {
- BConsole16bit = Object.create(GameConsole.prototype).load = function(gamename) {
- CConsole16bit.prototype.load(gamename) = function() {
- DConsole16bit.prototype.load = function(gamename) {
93Refer to the following code:
What is returned by the function call on line 13?
- Aundefined
- B'Null value!'
- CLine 13 throws an error.
- D'Undefined value!'
94A developer is debugging a web server that uses Node.js. The server hits a runtime error 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 the 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 breakpoint is hit?- Anode -i index.js
- Bnode --inspect -brk index.js
- Cnode --inspect index.js
- Dnode inspect index.js
95Refer to the code below:
What is the result of the code block?
- AThe console logs 'flag' and 'another flag'
- BThe console logs 'flag' and then an error is thrown
- CAn error is thrown
- DThe console logs only 'flag'
96A developer is wondering whether to use, Promise.then or Promise.catch, especially when a promise throws an error.
Which two promises are rejected?
Choose 2 answers.- APromise.reject('Cool error here').then(error => console.error(error));
- Bnew Promise(() => {throw 'Cool error here'}).then((null, error => console.error(error)));
- Cnew Promise((resolve, reject) => {throw 'Cool error here'}).catch(error => console.error(error));
- DPromise.reject('cool error here').catch(error => console.error(error));
97Refer to the following code that inports a module named Utils:
Which two implementations of Utils.js export foo and bar such that the code above runs without error?
Choose 2 answers.
- A.

- B/

- C,

- D;

- A.
98Refer to the code below:
Considering that JavaScript is single-threaded, what is the output of line 08 after the code executes?
- A10
- B11
- C12
- D13
99Refer to the code:
Given the requirement to refactor the code above to JavaScript class format, which class definition is correct?
- A.

- B/

- C,

- D'

- A.
100Which three statements are true about promises?
Choose 3 answers.- AA settled promise can become resolved
- BThe executor of a new Promise runs automatically
- CA fulfilled or rejected promise will not change states
- DA promise has a .then() method
- EA pending promise can become fulfilled, settled or rejected
101Which statement accurately describes the behaviour of the async/await keywords?
- AThe associated class contains some asynchronous functions
- BThe associated function can only be called via asynchronous methods
- CThe associated function will always return a promise
- DThe associated function sometimes returns a promise
102Considering type coercion, what does the following expression evaluate to?
true + 3 + '100' + null- A'3100null'
- B4100
- C104
- D'4100null'
103A 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.- AEnsures stability with one major release every few years
- BPerforms a static analysis on code before execution to look for runtime errors
- CInstalls with its own package manager to install and manage third-party libraries
- DUses non-blocking functionality for perform request handling
- EExecutes server-side JavaScript code to avoid learning a new language
104Which code statement correctly retrieves and returns an object from localStorage?
- A;

- B,

- C'

- D/

- A;
105Refer to the code below:
Why does the function bar have access to variable a?
- AInner function's scope
- BOuter function's scope
- CHoisting
- DPrototype chain
106Which three actions can be done using the JavaScript browser console?
- AView, change and debug the JavaScript code of the page
- BDisplay a report showing the performance of a page
- CRun code that is not related to the page
- DView and change security cookies
- EView and change the DOM of the page
107A 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 ws
The developer also wants to add error logging if a connection fails.
Given this information, which code segment shows the correct way to set up a client with two events that listen at execution time?- A/

- B'

- C;

- D.

- A/
108A 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?- AprintPrice must be a named export
- BprintPrice must be an all export
- CprintPrice must be the default export
- DprintPrice must be a multi export
109Why would a developer specify a package.json as a developed forge instead of a dependency?
- AIt is required by the application in production
- BIt is only needed for local development and testing
- COther required packages depend on it for development
- DIt should be bundled when the package is published
110Which three browser specific APIs are available for developers to persist data between page loads?
Choose 3 answers.- AIIFEs
- BIndexedDB
- CGlobal variables
- DCookies
- ElocalStorage
111Refer 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:- Alet x = arr.filter ((a) => (a<2));
- Blet x = arr.splice(2, 3);
- Clet x = arr.slice(2);
- Dlet x = arr.filter((a) => (return a>2));
- Elet x = arr.slice(2, 3);
112Which statement sorts the following number array so it is in ascending order?
const arr = [7, 3, 400, 10];- Aarr.sort();
- Barr.sort((a, b) => a-b);
- Carr.sort((a, b) => a<b);
- Darr.sort((a, b) => b-a);
113Given the following Animal constructor:
function Animal(size, age) {
this.size = size;
this.age = age;
this.canTalk = false;
}
Which method creates a new instance of the object?- AObject.create('Animal');
- Bnew Animal('large', 10);
- CObject.prototype(Animal);
- DObject.new(Animal);
114A developer wants to use a module called DatePrettyPrint. This module exports one default function called printDate().
How can a developer import and use the printDate() function?- Aimport printDate() from '/path/DatePrettyPrint.js';
printDate(); - Bimport printDate from '/path/DatePrettyPrint.js';
printDate(); - Cimport DatePrettyPrint from '/path/DatePrettyPrint.js';
DatePrettyPrint.printDate(); - Dimport printDate from '/path/DatePrettyPrint.js';
DatePrettyPrint.printDate();
- Aimport printDate() from '/path/DatePrettyPrint.js';
115A 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 personalizeWebsiteContent 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?- Awindow.addEventListener('onload', personalizeWebsiteContent);
- Bwindow.addEventListener('load', personalizeWebsiteContent);
- Cdocument.addEventListener('DOMContentLoaded', personalizeWebsiteContent);
- Ddocument.addEventListener('onDOMContentLoaded', personalizeWebsiteContent);
116Which two syntax examples correctly initialize a value to the variable strLang?
- Alet strLang = 'javascript';
- Bconst strLang = 'java' + 'script';
- Clet strLang = javascript;
- Dstr strLang = 'javascript';
117A 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 does not need to verify how many times the method has been called.
Which two test approaches describe the requirement?
Choose 2 answers:- AWhite box
- BStubbing
- CBlack box
- DSubstitution
118Refer to the code below:
Considering the implications of line 10 along with prototype inheritance, what is the value of result after the code executes?
- A100
- Bundefined
- Cnull
- D70
119The developer has a function that prints "Hello" to an input name. To test this, the developer created a function that returns "world". However, the following snippet does not print "Hello world".
What can the developer do to change the code to print "Hello World"?
- AChange line 2 to console.log('Hello', name());
- BChange line 7 to }();
- CChange line 5 to function world() {
- DChange line 9 to sayHello(world)();
120Refer 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.- AsampleText.substring('fox');
- BsampleText.includes('fox');
- CsampleText.includes('quick', 4);
- DsampleText.includes('Fox', 3);
- EsampleText.indexOf('quick') !== -1;
121Refer to the code below:
What is displayed when myFunction(true) is called?
- A2 2 2 2
- B2 2 undefined undefined
- C2 2 1 1
- D2 2 1 2
122A 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 requests against a local server to look at the behavior.
In the source code, the server.js file will start the server. The developer needs 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?- Anode server.js --inspect
- Bnode -i server.js
- Cnode start inspect server.js
- Dnode --inspect server.js
123A developer has code that calculates a restaurant bill but generates incorrect answers while testing the code.
Which option allows the developer to step into each function execution within caluclateBill?
- AWrapping findSubtotal in a console.log() method
- BUsing the debugger command on line 03
- CUsing the debugger command on line 05
- DCalling the console.trace(total) method on line 03
124Teams at Universal Containers (UC) work on multiple JavaScript projects at the same time. UC is thinking about reuseability 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?- APrivate packages are not supported, but they can use another package manager like yarn
- BPrivate registers are not supported by npm, but packages can be installed via git
- CPrivate packages can be scoped and scopes can be associated to a private registers
- DPrivate registers are not supported by npm, but packages can be installed via URL
125Given the following code:
What is logged by the first four log statements?
- A0 0 1 2
- B0 1 1 2
- C0 1 2 2
- D0 1 2 3
126A 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'

- B;

- C,

- D.

- A'
127A 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
- Bwindow.location
- Cthis.path
- D_dirname
128A 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.
What line replacement makes the code work as expected?
- A02 return arr.forEach({result, current} => )
- B03 if(arr.length == 0) {return 0; }
- C04 currenct = result + current;
- D05 return result;
129The developer wants to test this code:
const stringifyNumber = (num) => Number(num).toString();
Which two tests are the most accurate for this code?
Choose 2 answers:- Aconsole.assert(stringifyNumber() === 'NaN')
- Bconsole.assert(typeof stringifyNumber(2) === 'string')
- Cconsole.assert(stringifyNumber(-2) === '-2')
- Dconsole.assert(stringifyNumber('') == '0')
130Given the code below:
What is the expected output?
- ALine 08 outputs the variable, but line 09 throws an error
- BBoth lines 08 and 09 are executed, but the values outputted are undefined
- CLine 08 throws an error, therefore line 09 is never executed
- DBoth lines 08 and 09 are executed and the variables are outputted
131Given the code below:
What is logged to the console?
- A1 4 2 3 5
- B4 2 1 3 5
- C4 2 1 5 3
- D4 5 1 2 3
132Refer to the code below:
What is the value of result after the code executes?
- ANaN
- Bundefined
- C10
- D5
133Refer to the following code:
function Tiger() {
this.type = 'Cat';
this.size = 'large';
}
let tony = new Tiger();
tony.roar = () => {
console.log('They are great!');
};
function Lion() {
this.type = 'Cat';
this.size = 'large';
}
let leo = new Lion();
//insert code here
leo.roar();
Which two statements could be interested at line 17 to enable the function call on line 18?
Choose 2 answers:- Aleo.prototype.roar = () => {console.log('They are preety good!') ;};
- Bleo.roar = () => { console.log('They are preety good!'); };
- CObject.assign(leo, Tiger);
- DObject.assign(leo, tony);
134Refer to the HTML below:
Which JavaScript statements results in changing "Leo" to "The Lion"?
- Adocument.querySelector('&main li:second-child').innerHTML = 'The Lion';
- Bdocument.querySelectorAll('&main &Leo').innerHTML = 'The Lion';
- Cdocument.querySelector('&main li:nth-child(1)').innerHTML = 'The Lion';
- Ddocument.querySelectorAll('&main li.Leo').innerHTML = 'The Lion';
135Refer to the following code block:
What is the console output?
- A> Puppy is barking
- B> Undefined
- C> Puppy is making a sound
- D> Uncaught ReferenceError
136Refer to the code below:
A developer imports a library that creates a web server. The imported library uses events and callbacks to start the server.
Which code should be inserted at line 03 to set up an event and start the web server?
- Aserver.start();
- Bserver();
- Cserver.on('connect', (port) => {
console.log('Listening on', port);
}); - Dserver((port) => {
console.log('Listening on', port);
});
137A developer tries to retrieve all cookies, then sets a certain key value pair in the cookie. These statements are used:
01 document.cookie;
02 document.cookie = 'key=John Smith';
What is the behavior?- ACookies are read and the key value is set and all cookies are wiped
- BCookies are read and the key value is set, the remaining cookies are unaffected
- CCookies are not read because line 01 should be document.cookies, but the key value is set and all cookies are wiped
- DCookies are read, but the key value is not set because the value is not URL encoded
138A team that works on a big project uses npm to deal with project's dependencies.
A developer added a dependency to manipulate dates and pushed the updates to the remote repository. The rest of the team complaints that the dependency does not get downloaded when they execute npm install.
Which two reasons could be possible explanations for this?
Choose 2 answers.- AThe developer missed the option -add when adding the dependency
- BThe developer missed the option --save when adding the dependency
- CThe developer added the dependency as a dev dependency, and NPM_ENV is set to production
- DThe developer added the dependency as a dev dependency and NODE_ENV is set to production
139Refer to the code below:
A developer receives feedback from the Tech Lead that the code gives an error.
Which line edit should the developer make so this code runs?
- A02 let year = 2019;
- B03 if(monthName === July) {
- C02 const year = '2019';
- D03 if(monthName == 'July') {
140Universal 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. To address this problem, UC decides to implement a debounce function on the search string change handler.
What are three key steps to implement this debounce function?
Choose 3 answers.- AEnsure that the network request has the property debounce set to true
- BIf there is an existing setTimeout and the search string changes, allow the existing setTimeout to finish and do not require a new setTimeou
- CWhen the search string changes, enqueue the request within a setTimeout
- DStore the timerId of the setTimeout last enqueued by the search string change handler
- EIf 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
141A developer created a generic function to log custom messages in the code below.
Which three options can the developer use to log custom messages in the console?
- Adebug
- Btrace
- Cerror
- Dcount
- Egroup
142A developer has an isDog function that takes one argument, pet. They want to schedule the function to run every minute. What is the correct syntax for scheduling this function?
- AsetTimeout(isDog('cat') 60000);
- BsetInterval(isDog('cat'), 60000);
- CsetInterval(isDog, 60000, 'cat');
- DsetTimeout(isDog, 60000, 'cat');
143In the browser, the document object is often used to assign variables that require the broadest scope in an application.
Node.js applications do not have access to the document object by default.
Which two methods are used to address this?
Choose 2 answers.- AAssign variables to module.exports and require them as needed
- BUse the window object instead
- CCreate a new document object in the root file
- DAssign variables to the global object
144Refer to the code declarations below:
let str1 = 'Java';
let str2 = 'Script';
Which three expressions return the string JavaScript?
Choose 3 answers:- Astr1.join(str2);
- Bstr1.concat(str2);
- Cconcat(str1, str2);
- D'${str1}${str2}';
- Estr1 + str2
145Which three options show valid methods for creating a fat arrow function?
- Ax, y, z => { console.log('executed'); }
- B[] => { console.log('executed')' }
- CX => { console.log('executed'); }
- D(x, y, z) => { console.log('executed'); }
- E() => { console.log('executed'); }
146Given the following code, what is the value of x?
let x = '15' + (10*2);- A35
- B50
- C1520
- D3020
147The 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:- Aconsole.assert(arr[0] && arr[arr.length] === 0);
- Barr.forEach(elem => console.assert(elem === 0));
- Cconsole.assert(arr.length === 5);
- Dconsole.assert(arr.length > 0);
148Given the code below:
let numValue = 1982;
Which three code segments result in a correct conversion from number to string?
Choose 3 answers:- Alet strValue = numValue.toString();
- Blet strValue = '' + numValue;
- Clet strValue = numValue.toText();
- Dlet strValue = String(numValue);
- Elet strvalue = (String) numValue;
149Refer to the expression below:
let x = ('1' + 2) == (6*2);
How should this expression be modified to ensure that x evaluates to false?- Alet x = (1+2) === (6/2);
- Blet x = ('1' + 2) === (62);
- Clet x = (1+2) == ('6'/2);
- Dlet x = ('1' + '2') == (6*2);
150A developer uses a parsed JSON string to work with user information as shown in the code block below:
Which two options access the age attribute in the object?
Choose 2 answers.
- AuserInformation.get('age');
- BuserInformation.age;
- CuserInformation('age');
- Dconst {age} = userInformation
151Which two code snippets show working examples of a recursive function?
Choose 2 answers:- A'

- B,

- C;

- D.

- A'
152Which function should a developer use to repeatedly execute code at a fixed time interval?
- AsetTimeout
- BsetInterval
- CsetPeriod
- DsetInterim
153Refer to the following array:
let arr1 = [1, 2, 3, 4, 5];
Which two lines of code result in a secondary array, arr2, being created such that arr2 is a not reference to arr1?
Choose 2 answers.- Alet arr2 = Array.from(arr1);
- Blet arr2 = arr1.slice(0, 5);
- Clet arr2 = arr1;
- Dlet arr2 = arr1.sort();
154A developer creates an object where it prevents new properties from being added to it and makes all existing properties as non-configurable. Values of present properties can still be changed as long as they are writable.
Which method should be used to execute this business requirement?- AObject.freeze()
- BObject.seal()
- CObject.lock()
- DObject,cons()
155Refer to the code below:
In which sequence will the numbers be logged?
- A0 1 2 3 4
- B0 0 2 4 1 3
- C1 3 0 2 4
- D0 2 4 3 1
156Refer to the code below:
Which two functions can replace line 01 and return 58 to sum?
Choose 2 answers.
- Aconst addBy = (num1) => (num2) => num1 + num2;
- Bconst addBy = function(num1) {
return num 1 * num2;
} - Cconst addBy = (num1) => num1 + num2;
- Dconst addBy = function(num1) {
return function(num2) {
return num1 + num2;
}
}
157Refer to the following code:
let codeName = 'Bond''
let sampleText = 'The name is ${codeName}, Jim ${codeName}!';
A developer is trying to determine if a certain substring is part of a string.
Which three code statements return true?- AsampleText.includes('Jim', 4);
- BsampleText.substring('Jim');
- CsampleText.includes('Jim');
- DsampleText.indexOf('Bond') !== -1;
- EsampleText.includes('The', 0);
158A developer copied a JavaScript object:
How does the developer access dan's firstName, lastName?
Choose 2 answers:
- Adan.name
- Bdan.name()
- Cdan.firstName + dan.lastName
- Ddan.firstName() + dan.lastName()
159A 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?- AAngular
- BGatsby
- CExpress
Information
- Description
- Quiz on JD1, created by Digir Digir on 04/02/2023.
- Author
- Digir Digir
- Language
- English
- Views
- 39
- Rating
- No ratings yet Rate this quiz