JS1 Updated Flashcards
A developer initiates a server with the file server,js and adds dependencies in the source codes package,json that
are required to run the server.
Which command should the developer run to start the server locally?
A. start server,js
B. npm start server,js
C. npm start
D. node start
C
After user acceptance testing, the developer is asked to change the webpage background based on user’s
location. This change was implemented and deployed for testing.
The tester reports that the background is not changing, however it works as required when viewing on the
developer’s computer.
Which two actions will help determine accurate results?
Choose 2 answers
A . The developer should inspect their browser refresh settings.
B . The tester should disable their browser cache.
C . The developer should rework the code.
D . The tester should clear their browser cache.
A, D
A developer wants to use a module called DataPrettyPrint. This module exports one default function called
printDate ().
How can a developer import and use the printDate() function?
A. import DataPrettyPrint from ‘/path/DataPrettyPrint.js’/
DataPrettyPrint.printDate();
B. import printDate from ‘/path/DataPrettyPrint.js’/
printDate();
C. import printDate from ‘/path/DataPrettyPrint.js’/
DataPrettyPrint.printDate();
D. import DataPrettyPrint() from ‘/path/DataPrettyPrint.js’/
printDate();
B
A 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?
A . On the browser JavaScript console
B . On the terminal console running the web server
C . In the browser performance tools log
D . On the webpage console log
A
A developer at Universal Containers is creating their 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 initializations.
Which implementation should be used to call Fe:s:-a;::eHec5;te::.-.ter.: based on the business requirement above?
A . Add a listener to the window object to handle the DOMContentLoaded event
B . Add a handler to the personalizeWebsiteContent script to handle the load event
C . Add a listener to the window object to handle the lead event
D . Add a handler to the personalizeWebsiteContent script to handle the DOMContentLoaded event
C
Given the following code:
01 lext x = null;
02 console.log(typeof x);
What is the output of line 02?
A . ‘null’
B . ‘x
C . ‘undefined’ 0
D . ‘object’
D
A developer tries to retrieve all cookies, then sets a certain key value pair in the cookie. These statements are
used:
01 document.cookie;
02 documet.cookie = ‘key=John Smith’;
What is the behavior?
A . Cookies are read, but the key value is not set because the value is not URL encoded.
B . Cookies are not read because line 01 should be document, cookies, but the key value is set and all cookies are
wiped.
C . A Cookies are read and the key value is set, the remaining cookies are unaffected.
D . Cookies are read and the key value is set, and all cookies are wiped.
C
Given the JavaScript below:
01 function filterDOM(searchString){
02 const parsedSearchString = searchsting && searchsting.toLowerCase();
03 document.querySelectorAll(‘.account’).forEach(account => {
04 const accountName = account.innerHTML.toLowerCase();
05 account.style.display = accountName.include(parseSearchString) ? //InsertCodeHere//
06 });
07 }
Which code should replace the placeholder comment on line 06 to hide accounts that do not match the search
string?
A . ‘None’ : ‘block’
B . ‘Visible : ‘hidden’
C . ‘Hidden, visible
D . ‘Block’ : ‘none
D
Refer to the code below:
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?
A . Resolved1 Resolved2 Resolved3 Resolved4
B . Rejected
C . Rejected Resolved
D . Rejected1 Rejected2 Rejected3 Rejected Rejected Rejected4
C
Refer to the code below:
const car = {
price:100,
getPrice:function(){
return this.price;
}
};
const customCar = Object.create(car);
customCar.price = 70;
delete customCar.price;const result = customCar.getPrice();
What is the value of result after the code executes?
A . 100
B . undefined
C . null
D . 70
A
Refer to the following code:
class Vehicle{
constructor(plate){
this.plate = plate;
}
}
class Truck extends Vehicle{
constructor(plate, weight){
//Missing code
this.weight = weight;
}
displayWeight(){
console.log(The truck ${this.plate} has a weight of ${this.weight}lb.
);
}
}let myTruck = new Truck(‘123Ab’,5000);
myTruck.displayWeight();
Which statement should be added to missing code for the code to display ‘The truck 123AB has a
weight of 5000lb.
A . super(plate)
B . super.plate = plate
C . Vehicle.plate = plate
D . this.plate = plate
A
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
A
Refer to the code below
let inArray = [[1,2],[3,4,5]];
which two statements results in the array [1,2,3,4,5]?
choose 2 answer
A . [ ].concat(…inArray);
B . [ ].concat.apply(inArray,[ ]);
C . [ ].concat([…inArray])
D . [ ].concat.apply([ ],inArray);
A, D
At Universal Containers, every team has its own way of copying JavaScript objects. The code snippet shows an
Implementation from one team:
01 function Person() {
02 this.firstName = ‘John’:
03 this.lastName = ‘Doe’;
04 this.name = () => {
05 console.log(‘Hello $(this.firstName) $(this.lastName)’))
07 }
08}
09 const john = new Person();
10 const dan = JSON.stringify(JSON.parse(john));
11 dan.firstName = ‘Dan’;
12 dan.name();
What is the output of the code execution?
A . Hello John Doe
B . Hello Dan
C . Hello Dan Doe
D . SyntaxError: Unexpected token in JSON
D
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
C
Given the code below:
const delay = async delay =>{
return new Promise((resolve,reject)=>{
console.log(1);
setTimeout(resolve,deleay);
});
};
const callDelay = async ()=>{
console.log(2);
const yup = await delay(1000);
console.log(3);
}
console.log(4);
callDelay();
console.log(5);
What is logged to the console?
A . 4 2 1 5 3
B . 4 2 1 5 6
C. 4 5 1 2 3
D. 4 5 2 3 1
A
Refer to the code below:
let car1 = new Promise((_ ,reject)=> setTimeout(reject,2000,’Car1 crashed in’));
let car2 = new Promise(resolve => setTimeout(resolve,1500,’Car2 completed’));
let car3 = new Promise(resolve => setTimeout(resolve,3000,’Car3 completed’));
Promise.race([car1,car2,car3])
.then(value=>{
let result = ${value} the race.
;
}).catch(err=>{
console.log(‘Race is cancelled.’,err);
});
What is the value of result when promise.race execues?
A. Car1 completed the race.
B. Car2 completed the race.
C. Car3 completed the race.
D Race is cancelled.
B
Given the following code:
let x = null;
console.log(typeof x);
What is the output?
A . ‘object’
B . ‘undefined’
C . ‘null’
D . ‘x’
A
Refer to the code below:
01 document.body.addEventListner(‘click’,(event)=>{
02 if(//Answer Goes here//){
03 console.log(‘myElement clicked);
04 }
05 });
Which replacement for the conditional statement on line 02 allows a developer to correctly determine
that a specific element, myElement on the page had been clicked?
A. event.target.id ==’myElement’
B. event.target ==’myElemnt’
C. event
D. target.id == ‘myElement’
A
Refer to the HTML below:
//<div id='main'>
//<ul>
//<li>Leo</li>
//<li>Tony</li>
//<li>Tiger</li>
//</ul>
//</div>
Which JavaScript statement results in changing ‘’ The Lion.’’?
A . document.querySelectorAll(‘$main $TONY’).innerHTML = ‘’’ The Lion
B . document.querySelector(‘$main li:second-child’).innerHTML = ‘’ The Lion ‘;
C . document.querySelector(‘$main li.Tony’).innerHTML = ‘’’ The Lion ‘;
D . document.querySelector(‘$main li:nth-child(2)’),innerHTML = ‘’ The Lion. ‘;
A
Refer to the following code:
//<html lang=’en;>
//<body>
//<span onclick=’console.log(‘Span Message);”>
//<button> Send Message</button>
//</span>
//</body>
//
function displayMessage(ev){
ev.stopPropagation();
console.log(‘button message’);
}
const elem = document.getElementById(‘mybutton’);
elem.addEventListner(‘click’, displayMessage);
//</script>
//</html>
A . document.querySelectorAll(‘$main $TONY’).innerHTML = ‘’’ The Lion
B . document.querySelector(‘$main li:second-child’).innerHTML = ‘’ The Lion ‘;
C . document.querySelector(‘$main li.Tony’).innerHTML = ‘’’ The Lion ‘;
D . document.querySelector(‘$main li:nth-child(2)’),innerHTML = ‘’ The Lion. ‘;
A
Given the HTML below:
//<div>
//<div id='row-wc'>Univeral 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. document.querySelector(‘#row-as’).classList.add(‘priority-account’);
B. document.query (‘#row-as’).classList.add(‘priority-account’);
C. document.querySelector(‘#row-wc’).classList.add(‘priority-account’);
D. document.query (‘#row-bt’).classList.add(‘priority-account’);
A
Refer to the following code block:
class Animal{
constructor(name){
this.name = name;
}
makeSound(){
console.log(${this.name} is making a sound.
)
}
}
class Dog extends Animal{
constructor(name){
super(name)
this.name = name;
}
makeSound(){
console.log(${this.name} is barking.
)
}
}
let myDog = new Dog(‘Puppy’);
myDog.makeSound();
What is the console output?
A . Puppy is barking
B . Puppy is cracking
C. Puppy is making a sound
D. Undefined
A
A developer has an is Dog function that takes one argument cat. They want to schedule the function to run every
minute.
What is the correct syntax for scheduling this function?
A developer has an is Dog function that takes one argument cat. They want to schedule the function to run every
minute.
What is the correct syntax for scheduling this function?
A . setInterval(isDog, 60000,’cat’);
B . setInterval(isDog, 50000,’cat’);
C . setTimeout(isDog, 60000,’cat’);
D . setTimeout(isDog, 50000,’cat’);
A
Refer to the string below.
Const str=’Salesforce’;
Which two statements results in the word ‘Sales’?
Pick 2
A. Str.substring(0,5);
B. Str.substring(1,5);
C. Str.substr(0,5);
D. Str.substr(1,5);
A, C
Refer the code below.
x=3.14;
function myfunction() {
‘use strict’;
y=x;
}
z=x;
myFunction();
Pick 3
A . Z is equal to 3.14
B. USe string affects the rest of the page
C. Use strict has effect only on line 5.
D. Line 5 throws an error
E. USe string affect line 3 and down
A, C, D
Refer the following code
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);
i–;
}
console.log(array);
what is the value of array after code executes?
A. [1,2,3,5]
B. [1,2,3,4]
C. [4,5,4,4]
D. [4,4,5,4]
A
Refer to the code:
function Animal (size, type) {
this.size = size || ‘small’;
this.type = type || ‘Animal’;
this.cantalk = false;
}
let pet = function (size, type, name, owner){
Animal.call(this, size, type);
this.name = name;
this.owner = owner;
pet prototype = object.create(Animal.prototype);
let pet1 = new Pet();
Given the code above, which three properties are set for pet1?
Choose 3 answers
A . name
B . owner
C . type
D . canTalk
E . size
C,D,E
A developer has an ErrorHandler module that contains multiple functions.
What kind of export should be leveraged so that multiple functions can be used?
A . all
B . named
C . multi
D . default
B
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
B
Refer to the following code:
01 fucntion Tiger() {
02 this.type = ‘Cat’;
03 this.size = ‘large’;
04 }
05
06 let Tony = new Tiger();
07 tony.roar = () => {
08 console.log(‘They're great!’);
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 statement could be inserted at line 17 to enable the function call on line 18?
Choose 2 answers
A . Object.assign (leo, tony);
B . Object.assign (leo. Tiger);
C . leo.roar = () => { console.log(‘They're pretty good!’); );
D . leo.prototype.roar = ( ) =>( console.log(‘They're pretty good!’); };
A,C
Given the JavaScript below:
01 function filterDOM(searchString){
02 const parsedSearchString = searchsting && searchsting.toLowerCase();
03 document.querySelectorAll(‘.account’).forEach(account => {
04 const accountName = account.innerHTML.toLowerCase();
05 account.style.background = accountName.include(parseSearchString) ? //InsertCodeHere//
06 });
07 }
Which code should replace the placeholder comment on line 05 to highlight accounts that match the search
string’
A . ‘yellow’ : null
B . null : ‘yellow’
C . ‘none1 : ‘yellow’
D . ‘yellow : ‘none’
D
Refer to the string below:
const str = ‘Salesforce’;
Which two statements result in the word ‘Sales’?
Choose 2 answers
A . str.substr(1, 5);
B . str.substr (0, 5);
C . str.substring (1, 5);
D . str.substring (0, 5);
B,D
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?
Choose 2 answers
A . Gatsby
B . Angular
C . Express
D . Koa
B,C
Given the HTML below:
//<div>
// <div id ="row-uc">Univeral 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 Universal Containers row?
A . document.querySelector (#row-uc’).classes-push(‘priority-account’);
B . document.getElementByid(‘row-uc’).addClass(‘priority-account*);
C . document.querySelectorAll(‘#row-uc’) -classList.add(‘priority-accour’);
D . document.queryselector(‘#row-uc’).ClassList.add(‘priority-account’);
D
01 setTimeout (() => {
02 console.log(1);
03 ),1100);
04 console.log(2);
05 new Promise ((resolve, reject) => {
06 setTimeout (() => {
07 console.log(3);
08 },1000);
09}}.catch(() => {
10 console.log(4);
11 });
12 console.log(5);
What is logged to the console
A . 1 2 3 4 5
B . 1 2 5 3 4
C . 2 5 1 3 4
D . 2 5 3 4 1
D
Given the code below:
Which three code segments result in a correct conversion from number to string?
Choose 3 answers
A . let strValue = numValue. toString();
B . let strValue = * * 4 numValue;
C . let strValue = numValue.toText ();
D . let scrValue = String(numValue);
E . let strValue = (String)numValue;
A,B,D
Given the following code, what is the value of x?
let x = ‘15’ + (10 * 2);
A . 35
B . 50
C . 1520
D . 3020
C
A developer wants to create an object from a function in the browser using the code below.
01 function Monster(){ this.name = hello };
02 const = Monster();
What happens due to the lack of the mm keyword on line 02?
A . window.name is assigned to ‘hello’ and the variable = remains undefined.
B . window.m Is assigned the correct object.
C . The m variable is assigned the correct object but this.name remains undefined.
D . The m variable is assigned the correct object.
A
A developer has the following array of hourly wages:
Let arr = (8, 5, 9, 75, 11, 25, 7, 75, , 13, 25);
For workers making less than $10 an hour rate should be multiple by 1.25 and returned in a new array.
How should the developer implement the request?
A . let arrl = arr.filter((val) => val < 10).map((num) -> num = 1.25);
B . let arrl = arr .rr.acArray ((val) => ( val < 10 )) ,map((num) => { num * 1.25 ));
C . let arrl = arr-map((num) => { return ran * 1.25 }).filter((val) -> { return val < 10));
D . let arrl = arr.filterBy((val) => val < 10 ).aapBy<(num) -> num = ..25 );
C
Refer to the code declarations below:
let str1 = ‘Java’;
let str2 = ‘Script’;
Which three expressions return the string JavaScript?
Choose 3 answers
A . Str1.join (str2);
B . Str1.concat (str2);
C . Concat (str1, str2);
D . $(str1) $ (str2} ‘;
E . Str1 + str2;
B,D,E
Refer to the following code:
let obj = {
foo: 1,
bar: 2
}
let output = [];
for(let something of obj) {
output.push(somehting);
}
console.log(output);
A . [1, 2]
B . ['’foo’’, ‘‘bar’’]
C . ['’foo’‘:1, ‘‘bar’‘:2’’]
D . An error will occur due to the incorrect usage of the for…of statement on line 07.
D
Refer to the following array:
Let arr = [1, 2, 3, 4, 5];
Which three options result in x evaluating as [1, 2]?
Choose 3 answer
A . let x = arr. slice (2);
B . let x = arr. slice (0, 2);
C . let x arr.filter((a) => (return a <= 2 });
D . let x = arr.filter ((a) => 2 }) ;
E . let x =arr.splice(0, 2);
B,C,E
Refer to the following code:
class Ship{
constructor(size) {
this.size = size;
}
}
class FinishingBoat extends ship {
constructor(size, capacity) {
// missing code
this.capacity = capacity;
}
displyaycapacity(){
console.log(‘This boat has a capacity of $(this.capacity) people);
}
}
let myBoat = new FinishingBoat (‘medium’ 10 );
myBoat.displayCapacity();
Which statement should be added to line 09 for the code to display ‘The boat has a capacity of 10 people?
A . super.size = size;
B . ship.size = size;
C . super (size);
D . this.size = size;
D
Refer to the code below:
const myFunction = arr => {
return arr.reduce((result, current) => {
return result + current;
}, 5);
What is the output of this function when called with an empty array?
A . Return 0
B . Return 5
C . Return NaN
D . Return Infinity
B
A developer at Universal Containers is creating their new landing page based on HTML, CSS, and JavaScript. The
website includes multiple external resources that are loaded when the page is opened.
To ensure that visitors have a good experience, a script named personalizeWebsiteContent needs to be executed
when the webpage Is loaded and there Is no need to wait for the resources to be available.
Which statement should be used to call personalizeWebsiteContent based on the above business requirement?
A . windows,addEventListener(‘load’, personalizeWebsiteContent);
B . windows,addEventListener(‘DOMContent Loaded ‘, personalizeWebsiteContent);
C . windows,addEventListener(‘onload’, personalizeWebsiteContent);
D . windows,addEventListener(‘onDOMCContentLoaded’, personalizeWebsiteContent);
A
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 . window.location
B . _filename
C . _dirname
D . this.path
B
A developer copied a JavaScript object:
function person(){
this.firstName = ‘John’;
this.LastName = ‘Doe’;
this.name = () => ‘${this.firstName},${this.LastName};
}
const john = new person();
const dan = object.assign(john);
dan.FirstName = ‘Dan;
How does the developer access dan’s forstName,lastName? Choose 2 answers
A . dan.name
B . dan.firstname ( ) + dan.lastName ( )
C . dan.firstName = dan.lastName
D . dan.name ( )
B, D
There is a new requirement for a developer to implement a currPrice method that will return the current price of
the item or sales..
01 let regItem = new item(scarf , 50);
02 let salesItem = new SalesItem(shirt, 80, .1);
03 Item.protoType.currPrice = function() { return this.price }
04 console.log(regItem.currPrice());
05 console.log(saleItem.currPrice());
06
07 Saleitem.protoType.currPrice = function() { return this.price = this.price * this. discount}
08 console.log(regItem.currPrice());
09 console.log(saleItem.currPrice());
What is the output when executing the code above
A . 50
Uncaught TypeError: saleItem,desrcription is not a function
50
80
B . 50
80
50
72
C . 50
80
72
D . 50
80
Uncaught Reference Error:this,discount is undefined
72
B
Given the following code:
01 counter = 0
02 const logCounter = () => (
03. console.log(counter);
04 );
05 logCounter();
06 setTimeout(logCounter, 2100);
07 setInterval(() => {
08 counter ++
09 logCounter();
10 ), 1000);
What will be the first four numbers logged?
A . 0012
B . 0112
C . 0122
D . 0123
B
Refer to the following object.
01 const dog = {
02 firstName: ‘Beau’,
03 lastName: ‘Boo’,
04 get fullName() {
05 return this.firstName + ‘ ‘ + this.LastName;
06 }
07 );
How can a developer access the fullName property for dog?
A . Dog.fullName
B . Dog.fullName ( )
C . Dog, get, fullName
D . Dog, function, fullName
A
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
B
Given the expressions var1 and var2, what are two valid ways to return the concatenation of the two expressions
and ensure it is string?
Choose 2 answers
A . var1 + var2
B . var1.toString ( ) var2.toString ( )
C . String (var1) .concat (var2)
D . string.concat (var1 +var2)
B,D
bar, awesome is a popular JavaScript module. the versions publish 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.
{
“name”: “UC Project Extra”;
“version”: “0.0.5”
“dependencies”: {
“bar.awesome”: “~1.3.0”
}
}
A developer runs this command: npm install.
Which version of bar .awesome is installed?
A . 1.3.1
B . 1.3.5
C . The command fails, because version 130 is not found
D . 1.4.0
B
A 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. Try{ doSomeything(); }Catch (error){ return error; }
B. Try{ doSomeything(); }Catch (error){ return null; }
C. Try{ doSomeything(); }Catch (error){ Throw new error (Error Found); }
D. Try{ doSomeything(); }Catch (error){ ProcessError(error); }
D
Which two options are core Node.js modules?
Choose 2 answers
A . worker
B . isotream
C . exception
D . http
B, D
Refer to the code below:
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 . Error: myFather.job is not a function
B . John Developer
C . undefined Developer
D . John undefined
B
Refer to the code below:
let country = {
get capitol () {
let city = Number(“London”);
return {
cityString: city.toString(),
}
}
}
Which value can a developer expect when referencing country,capital,cityString?
A . ‘London’
B . undefined
C . An error
D . ‘NaN’
D
Given the code below:
function Person(name, email) {
this.name = name;
this.email = email;
}
const john = new Person (John, john@email.com’);
const jane = new Person (Jane, jane@email.com’);
const emily = new Person (Emily, emily@email.com’);
let userList = [john, jane, emily];
Which method can be used to provide a visual representation of the list of users and to allow sorting by the name
or email attribute?
A . console.group(usersList) ;
B . console.table(usersList) ;
C . console.info(usersList) ;
D . console.groupCol lapsed (usersList) ;
A
Refer to the code below:
01 let total = 10;
02 const interval = setInterval (() => {
03 total ++;
04 clearInterval (interval);
05 total++;
0+ ),0);
07 total ++;
08 console.log(total);
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
B
Refer to the following code block:
class student {
constructor(name) {
this.name = name;
}
takeTest() {
console.log(‘$(this.name ) got 70% on test)
}
}
class BetterStudent extends Student {
constructor(name){
super(name);
this.name = ‘Better Student ‘ + name;
}
takeTest() {
console.log(‘$(this.name) got 100% on test);
}
}
let student = new BetterStudent(Jackie);
student.TakeTest();
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.
D
Which statement can a developer apply to increment the browser’s navigation history without a page refresh?
Which statement can a developer apply to increment the browser’s navigation history without a page refresh?
A . window.history.pushState(newStateObject);
B . window.history.pushStare(newStateObject, ‘ ‘, null);
C . window.history.replaceState(newStateObject,’ ‘, null);
D . window.history.state.push(newStateObject);
C
Considering the implications of ‘use strict’ on line 04, which three statements describe the execution of the code?
Choose 3 answers
A . z is equal to 3.14.
B . ‘use strict’ is hoisted, so it has an effect on all lines.
C . ‘use strict’ has an effect only on line 05.
D . ‘use strict’ has an effect between line 04 and the end of the file.
E . Line 05 throws an error.
A,C,E
Refer to the following code:
let obj = {
foo: 1,
bar: 2
}
let output = [];
for(let something in obj) {
output.push(somehting);
}
console.log(output);
A . [1,2]
B . [‘bar’, ‘foo’]
C . [‘foo:1’, ‘bar:2’]
D . [‘foo’, ‘bar’]
D
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);
A
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 nag is declared and assigned a value on line 03.
function getAvailableabilityMessage (item) {
if (getAvailability(item)){
var msg = ‘Username available’;
}
return msg;
}
What is the value of msg when getAvailableabilityMessage
(‘‘newUserName’’) is executed and getAvailability
(‘‘newUserName’’) returns true?
A . ‘msg is not defined’
B . ‘newUserName’
C . ‘Username available’
D . undefined
C
Refer of the string below:
Const str = ‘salesforce’=;
Which two statement result in the word ‘Sale’?
Choose 2 answers
A . str, substring (0,5) ;
B . str, substr(0,5) ;
C . str, substring(1,5) ;
D . str, substr(1,5) ;
A,B
developer uses the code below to format a date.
const date = new date(2020, 05, 10);
const displayoptions = {
year: numeric
month: long
day: numeric
};
const formattedDate = date.toLocaleDateString(‘en’, dateDispalyOptions);
After executing, what is the value of formattedDate?
A . May 10, 2020
B . June 10, 2020
C . October 05, 2020
D . November 05, 2020
A
Refer to the code below:
function changeValue(param){
param = 5;
}
let a = 10
let b = a
changeValue(b);
const result = a + ‘-‘ + b
What is the value of result when the code executes?
A . 10-10
B . 5-5
C . 10-5
D . 5-10
A
A 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 turnaround 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 latency period?
A . NODE_DEBUG=true node server.js
B . DEBUG=http, https node server.js
C . NODE_DEBUG=http,https node server.js
D . DEBUG=true node server.js
D
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, and the test passes.
A different developer made changes to the behavior of sum3 to instead sum only the first two numbers present in
the array.
let res = sum3([1,4,1])
console.assert(res===6);
let res = sum3([1,5,0,5])
console.assert(res===6);
Which two results occur when running this test on the updated sum3 function?
Choose 2 answers
A . The line 05 assertion passes.
B . The line 02 assertion passes.
C . The line 02 assertion fails.
D . The line 05 assertion fails.
B,D
Universal Containers (UC) just launched a new landing page, but users complain that the website is slow. A developer found some functions any 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.
console.time(‘Performace);
maybeHavyFunction();
thisCouldTakeTooLong();
orMaybeThisOne();
console.endtime(‘Performace’)
Which function can the developer use to obtain the time spent by every one of the three functions?
A . console. timeLog ()
B . console.timeStamp ()
C . console.trace()
D . console.getTime ()
A
A test has a dependency on database. query. During the test, the dependency is replaced with an object called
database with the method,
Calculator 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
A . White box
B . Stubbing
C . Black box
D . Substitution
A,D
Given the following code: is the output of line 02?
let x = null
console.log(type of x);
A . ‘‘x’’
B . ‘‘null’’’
C . ‘‘object’’
D . ‘‘undefined’’
C
Which statement parses successfully?
A . JSON.parse ( ‘ foo ‘ );
B . JSON.parse ( ‘’ foo ‘’ );
C . JSON.parse( ‘’ ‘ foo ‘ ‘’ );
D . JSON.parse(‘ ‘’ foo ‘’ ‘);
D
A 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?
A . setTimeout (formatName(), 5000, ‘John’, ‘BDoe’);
B . setTimeout (formatName(‘John’, ‘‘Doe’), 5000);
C . setTimout(() => { formatName(‘John’, ‘Doe’) }, 5000);
D . setTimeout (‘formatName’, 5000, ‘John’, ‘Doe’);
D
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. Try{
setTimeout(function(){
countSheep(); ),1000);
} catch(e){
handleError(e)
}
B. try{
countSheep();
} finally {
handleerror(e)
}
C. setTimeout(function() {
try{
countsheep();
} catch(e) (
handleerror(e);
)},1000);
D Try{
countsheep();
}handleError(e){
catch(e);
A
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’);
B,D
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?
A . import * from ‘/path/universalContainersLib.js’;
universalContainersLib. foo ()7
universalContainersLib.bar ();
B . import {foo,bar} from ‘/path/universalCcontainersLib.js’;
foo():
bar()?
C . import all from ‘/path/universalContainersLib.js’;
universalContainersLib.foo();
universalContainersLib.bar ();
D . import * as lib from ‘/path/universalContainersLib.js’;
lib.foo();
lib. bar ();
D
A developer wants to define a function log to be used a few times on a single-file JavaScript script.
01 // Line 1 replacement
02 console.log(‘‘LOG:’, logInput);
03 }
Which two options can correctly replace line 01 and declare the function for use?
Choose 2 answers
A . function leg(logInput) {
B . const log(loginInput) {
C . const log = (logInput) => {
D . function log = (logInput) {
A, C
Refer to the expression below:
Let x = (‘1’ + 2) == (6 * 2);
How should this expression be modified to ensure that evaluates to false?
A . Let x = (‘1’ + ‘ 2’) == ( 6 * 2);
B . Let x = (‘1’ + 2) == ( 6 * 2);
C . Let x = (1 + 2) == ( ‘6’ / 2);
D . Let x = (1 + 2 ) == ( 6 / 2);
B
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.
B
Refer to code below:
console.log(0);
setTimeout(() => (
console.log(1);
});
console.log(2);
setTimeout(() => {
console.log(3);
), 0);
console.log(4);
In which sequence will the numbers be logged?
A . 01234
B . 02431
C . 02413
D . 13024
C
Refer to code below:
Const objBook = {
Title: ‘Javascript’,
};
Object.preventExtensions(objBook);
Const newObjBook = objBook;
newObjectBook.author = ‘Robert’;
What are the values of objBook and newObjBook respectively ?
A . [title: ‘‘javaScript’’] [title: ‘‘javaScript’’]
B . {author: ‘‘Robert’’, title: ‘‘javaScript}
Undefined
C . {author: ‘‘Robert’’, title: ‘‘javaScript}
{author: ‘‘Robert’’, title: ‘‘javaScript}
D . {author: ‘‘Robert’’}
{author: ‘‘Robert’’, title: ‘‘javaScript}
A
Refer 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.
A . Let x= arr.filter (( a) => (a<2));
B . Let x= arr.splice(2,3);
C . Let x= arr.slice(2);
D . Let x= arr.filter((a) => ( return a>2 ));
E . Let x = arr.slice(2,3);
B,C,D
In the browser, the window object is often used to assign variables that require the broadest scope in an application Node.js application does not have access to the window object by default.
Which two methods are used to address this ?
Choose 2 answers
A . Use the document object instead of the window object.
B . Assign variables to the global object.
C . Create a new window object in the root file.
D . Assign variables to module.exports and require them as needed.
B
Refer to the code below:
Const myFunction = arr => {
Return arr.reduce((result, current) =>{
Return result = current;
}, 10};
}
What is the output of this function when called with an empty array ?
A . Returns 0
B . Throws an error
C . Returns 10
D . Returns NaN
C
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.
A, B, E
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 Option B?
A . 1 growl method is created for Option A. 1000 growl methods are created for Option B.
B . 1000 growl method is created for Option A. 1 growl methods are created for Option B.
C . 1000 growl methods are created regardless of which option is used.
D . 1 growl method is created regardless of which option is used.
B