JavaScript Developer I Salesforce Exam Practice Questions
JavaScript Developer I Salesforce Exam Practice Questions
What's Inside:
Important Note:
For full access to the complete question bank and topic-wise explanations, visit:
CertQuestionsBank.com
FB page: https://www.facebook.com/certquestionsbank
Share some JavaScript Developer I exam online questions below.
1.Refer to HTML below:
<div id =”main”>
<div id = “ card-00”>This card is smaller.</div>
<div id = “card-01”>
The width and height of this card is determined by its contents.
</div>
</div>
Which expression outputs the screen width of the element with the ID card-01?
A. document.getElementById(‘ card-01 ’).getBoundingClientRest().width
B. document.getElementById(‘ card-01 ’).style.width
C. document.getElementById(‘ card-01 ’).width
D. document.getElementById(‘ card-01 ’).innerHTML.lenght*e
Answer: A
5. A developer is leading the creation of a new browser application that will serve a single page
application. The team wants to use a new web framework Minimalsit.js. The Lead developer wants to
advocate for a more seasoned web framework that already has a community around it.
Which two frameworks should the lead developer advocate for? Choose 2 answers
A. Vue
B. Angular
C. Koa
D. Express
Answer: B,D
6. 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)
B)
C)
D)
A. Option
B. Option
C. Option
D. Option
Answer: A
7.A 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
A. let res = fizzbuzz(5);
console.assert ( res === ‘ ’ );
B. let res = fizzbuzz(15);
console.assert ( res === ‘ fizzbuzz ’ )
C. let res = fizzbuzz(Infinity);
console.assert ( res === ‘ ’ )
D. let res = fizzbuzz(3);
console.assert ( res === ‘ buzz ’ )
Answer: B,C,D
9. 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 alert ( ‘Hey! I am John Doe’) ;
03 button.addEventListener (‘click’, listen);
Which two code lines make this code work as required? Choose 2 answers
A. On line 02, use event.first to test if it is the first execution.
B. On line 04, use event.stopPropagation ( ),
C. On line 04, use button.removeEventListener(‘ click”, listen);
D. On line 06, add an option called once to button.addEventListener().
Answer: C,D
12. Teams at Universal Containers (UC) work on multiple JavaScript projects at the same time.
UC is thinking about reusability 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?
A. Private packages can be scored, and scopes can be associated to a private registries.
B. Private registries are not supported by npm, but packages can be installed via URL.
C. Private packages are not supported, but they can use another package manager like yarn.
D. Private registries are not supported by npm, but packages can be installed via git.
Answer: A
13. Universal 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 includes the same ad-library-item class, They are hidden by default, and they are
randomly displayed while the user navigates through the page.
A. Use the DOM inspector to prevent the load event to be fired.
B. Use the browser to execute a script that removes all the element containing the class ad-library-
item.
C. Use the DOM inspector to remove all the elements containing the class ad-library-item.
D. Use the browser console to execute a script that prevents the load event to be fired.
Answer: C
15. A 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:
Class Item {
constructor(name, price) {
… // Constructor Implementation
}
}
Class SaleItem extends Item { constructor (name, price, discount) {
...//Constructor Implementation
}
}
There is a new requirement for a developer to implement a description method that will return a brief
description for Item and SaleItem.
Let regItem =new Item(‘Scarf’, 55);
Let saleItem = new SaleItem(‘Shirt’ 80, -1);
Item.prototype.description = function () { return ‘This is a ’ + this.name;
console.log(regItem.description());
console.log(saleItem.description());
SaleItem.prototype.description = function () { return ‘This is a discounted ’ +
this.name; }
console.log(regItem.description());
console.log(saleItem.description());
What is the output when executing the code above?
A. This is a Scarf
Uncaught TypeError: saleItem.description is not a function
This is aScarf
This is a discounted Shirt
B. This is a Scarf
This is a Shirt
This is a Scarf
This is a discounted Shirt
C. This is a Scarf
This is a Shirt
This is a discounted Scarf
This is a discounted Shirt
D. This is aScarf
Uncaught TypeError: saleItem.description is not a function
This is a Shirt
This is a did counted Shirt
Answer: B
19.GIven a value, which three options can a developer use to detect if the value is NaN? Choose 3
answers
A. value == NaN
B. Object.is(value, NaN)
C. value === Number.NaN
D. value ! == value
E. Number.isNaN(value)
Answer: A,E
28. A 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?
A. const https =require(‘https’);
B. const server =require(‘secure-server’);
C. const tls = require(‘tls’);
D. const http =require(‘http’);
Answer: A
29. 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?
A. True positive
B. True negative
C. False positive
D. False negative
Answer: D
30. 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 number in the array,
The test passes:
Let res = sum2([1, 2, 3 ]) ;
console.assert(res === 6 );
Res = sum3([ 1, 2, 3, 4]);
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. The test passes:
Which two results occur when running the test on the updated sum3 function? Choose 2 answers
A. The line 02 assertion passes.
B. The line 02 assertion fails
C. The line 05 assertion passes.
D. The line 05 assertion fails.
Answer: A,D
31.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.
Answer: A,C,E