
Salesforce Certified JavaScript Developer (JS-Dev-101) - JavaScript-Developer-I Exam Questions
QUESTION NO: 1
Refer to the code:
01 const exec = (item, delay) = >
02 new Promise(resolve = > setTimeout(() = > resolve(item), delay));
03
04 async function runParallel() {
05 const [result1, result2, result3] = await Promise.all(
06 [exec( ' x ' , ' 100 ' ), exec( ' y ' , ' 500 ' ), exec( ' z ' , ' 100 ' )]
07 );
08 return `parallel is done: ${result1}${result2}${result3}`;
09 }
Which two statements correctly execute runParallel()?
Refer to the code:
01 const exec = (item, delay) = >
02 new Promise(resolve = > setTimeout(() = > resolve(item), delay));
03
04 async function runParallel() {
05 const [result1, result2, result3] = await Promise.all(
06 [exec( ' x ' , ' 100 ' ), exec( ' y ' , ' 500 ' ), exec( ' z ' , ' 100 ' )]
07 );
08 return `parallel is done: ${result1}${result2}${result3}`;
09 }
Which two statements correctly execute runParallel()?
Correct Answer: B,D
Explanation: Only visible for Pass4Test members. You can sign-up / login (it's free).
QUESTION NO: 2
A developer uses a parsed JSON string to work with user information as in the block below:
01 const userInformation = {
02 " id " : " user-01 " ,
03 " email " : " [email protected] " ,
04 " age " : 25
05 };
Which two options access the email attribute in the object?
A developer uses a parsed JSON string to work with user information as in the block below:
01 const userInformation = {
02 " id " : " user-01 " ,
03 " email " : " [email protected] " ,
04 " age " : 25
05 };
Which two options access the email attribute in the object?
Correct Answer: B,D
Explanation: Only visible for Pass4Test members. You can sign-up / login (it's free).
QUESTION NO: 3
Refer to the following array:
let arr = [1, 2, 3, 4, 5];
Which two lines of code result in a second array, arr2, created such that arr2 is a reference to arr?
Refer to the following array:
let arr = [1, 2, 3, 4, 5];
Which two lines of code result in a second array, arr2, created such that arr2 is a reference to arr?
Correct Answer: A,D
Explanation: Only visible for Pass4Test members. You can sign-up / login (it's free).
QUESTION NO: 4
A developer has a module that contains multiple functions.
What kind of export should be leveraged so that multiple functions can be used?
A developer has a module that contains multiple functions.
What kind of export should be leveraged so that multiple functions can be used?
Correct Answer: B
Explanation: Only visible for Pass4Test members. You can sign-up / login (it's free).
QUESTION NO: 5
Refer to the code below (corrected to use a template literal on line 08):
01 let car1 = new Promise((_, reject) = >
02 setTimeout(reject, 2000, " Car 1 crashed in " )
03 );
04 let car2 = new Promise(resolve = >
05 setTimeout(resolve, 1500, " Car 2 completed " )
06 );
07 let car3 = new Promise(resolve = >
08 setTimeout(resolve, 3000, " Car 3 completed " )
09 );
10
11 Promise.race([car1, car2, car3])
12 .then(value = > {
13 let result = `${value} the race.`;
14 })
15 .catch(err = > {
16 console.log( " Race is cancelled. " , err);
17 });
What is the value of result when Promise.race executes?
Refer to the code below (corrected to use a template literal on line 08):
01 let car1 = new Promise((_, reject) = >
02 setTimeout(reject, 2000, " Car 1 crashed in " )
03 );
04 let car2 = new Promise(resolve = >
05 setTimeout(resolve, 1500, " Car 2 completed " )
06 );
07 let car3 = new Promise(resolve = >
08 setTimeout(resolve, 3000, " Car 3 completed " )
09 );
10
11 Promise.race([car1, car2, car3])
12 .then(value = > {
13 let result = `${value} the race.`;
14 })
15 .catch(err = > {
16 console.log( " Race is cancelled. " , err);
17 });
What is the value of result when Promise.race executes?
Correct Answer: A
Explanation: Only visible for Pass4Test members. You can sign-up / login (it's free).
QUESTION NO: 6
Corrected code:
let a = " * " ;
let b = " ** " ;
// x = 3;
console.log(a);
What is displayed when the code executes?
Corrected code:
let a = " * " ;
let b = " ** " ;
// x = 3;
console.log(a);
What is displayed when the code executes?
Correct Answer: C
Explanation: Only visible for Pass4Test members. You can sign-up / login (it's free).
QUESTION NO: 7
A developer has 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 nor 5.
Which two test cases properly test scenarios for the fizzbuzz function?
A developer has 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 nor 5.
Which two test cases properly test scenarios for the fizzbuzz function?
Correct Answer: A,D
Explanation: Only visible for Pass4Test members. You can sign-up / login (it's free).
QUESTION NO: 8
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?
(With corrected typing errors: node_inspect # node inspect, node_start_inspect # node start inspect.)
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?
(With corrected typing errors: node_inspect # node inspect, node_start_inspect # node start inspect.)
Correct Answer: C
QUESTION NO: 9
Refer to the following code (correcting the missing template literal backticks):
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?
Refer to the following code (correcting the missing template literal backticks):
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?
Correct Answer: B,C,D
Explanation: Only visible for Pass4Test members. You can sign-up / login (it's free).




