Free Salesforce JS-Dev-101 Practice Test & Real Exam Questions
Refer to the following code:
01 class Ship {
02 constructor(size) {
03 this.size = size;
04 }
05 }
06
07 class FishingBoat extends Ship {
08 constructor(size, capacity){
09 //Missing code
10 this.capacity = capacity;
11 }
12 displayCapacity() {
13 console.log('The boat has a capacity of ${this.capacity} people.');
14 }
15 }
16
17 let myBoat = new FishingBoat('medium', 10);
18 myBoat.displayCapacity();
Which statement should be added to line 09 for the code to display
The boat has a capacity of 10 people?
01 class Ship {
02 constructor(size) {
03 this.size = size;
04 }
05 }
06
07 class FishingBoat extends Ship {
08 constructor(size, capacity){
09 //Missing code
10 this.capacity = capacity;
11 }
12 displayCapacity() {
13 console.log('The boat has a capacity of ${this.capacity} people.');
14 }
15 }
16
17 let myBoat = new FishingBoat('medium', 10);
18 myBoat.displayCapacity();
Which statement should be added to line 09 for the code to display
The boat has a capacity of 10 people?
Correct Answer: C
Vote an answer
Explanation: Only visible for Pass4Leader members. You can sign-up / login (it's free).
A developer implements a function that adds a few values.
function sum(num1, num2, num3) {
if (num3 === undefined) {
num3 = 0;
}
return num1 + num2 + num3;
}
Which three options can the developer invoke for this function to get a return value of 10?
function sum(num1, num2, num3) {
if (num3 === undefined) {
num3 = 0;
}
return num1 + num2 + num3;
}
Which three options can the developer invoke for this function to get a return value of 10?
Correct Answer: A,B,D
Vote an answer
Explanation: Only visible for Pass4Leader members. You can sign-up / login (it's free).
Given the following code:
let x = ('15' + 10) * 2;
What is the value of x?
let x = ('15' + 10) * 2;
What is the value of x?
Correct Answer: D
Vote an answer
Explanation: Only visible for Pass4Leader members. You can sign-up / login (it's free).
A developer wrote the following code:
01 let x = object.value;
02
03 try {
04 handleObjectValue(x);
05 } catch(error) {
06 handleError(error);
07 }
The developer has a getNextValue function to execute after handleObjectValue(), but does not want to execute getNextValue() if an error occurs. How can the developer change the code to ensure this behavior?
01 let x = object.value;
02
03 try {
04 handleObjectValue(x);
05 } catch(error) {
06 handleError(error);
07 }
The developer has a getNextValue function to execute after handleObjectValue(), but does not want to execute getNextValue() if an error occurs. How can the developer change the code to ensure this behavior?
Correct Answer: A
Vote an answer
Explanation: Only visible for Pass4Leader members. You can sign-up / login (it's free).
A developer is creating a simple webpage with a button. When a user clicks this button for the first time, a message is displayed.
The developer wrote the JavaScript code below, but something is missing. The message gets displayed every time a user clicks the button, instead of just the first time.
01 function listen(event) {
02
03 alert('Hey! I am John Doe');
04
05 }
06 button.addEventListener('click', listen);
Which two code lines make this code work as required?
The developer wrote the JavaScript code below, but something is missing. The message gets displayed every time a user clicks the button, instead of just the first time.
01 function listen(event) {
02
03 alert('Hey! I am John Doe');
04
05 }
06 button.addEventListener('click', listen);
Which two code lines make this code work as required?
Correct Answer: A,D
Vote an answer
Explanation: Only visible for Pass4Leader members. You can sign-up / login (it's free).
Given the HTML below:
<div>
<div id="row-uc">Universal Containers</div>
<div id="row-as">Applied Shipping</div>
<div id="row-bt">Burlington Textiles</div>
</div>
Which statement adds the priority-account CSS class to the Applied Shipping row?
<div>
<div id="row-uc">Universal Containers</div>
<div id="row-as">Applied Shipping</div>
<div id="row-bt">Burlington Textiles</div>
</div>
Which statement adds the priority-account CSS class to the Applied Shipping row?
Correct Answer: B
Vote an answer
Explanation: Only visible for Pass4Leader members. You can sign-up / login (it's free).
