ExamGecko
Ask Question

Salesforce Certified JavaScript Developer I Practice Test - Questions Answers

List of questions

Question 1

Report Export Collapse

Refer to the code below:

01 const exec = (item, delay) =>{

02 new Promise(resolve => setTimeout( () => resolve(item), delay)),

03 async function runParallel() {

04 Const (result1, result2, result3) = await Promise.all{

05 [exec ('x', '100') , exec('y', 500), exec('z', '100')]

06 );

07 return `parallel is done: $(result1) $(result2)$(result3)`;

08 }

}}

Which two statements correctly execute the runParallel () function?

Choose 2 answers

Async runParallel () .then(data);
Async runParallel () .then(data);
runParallel ( ). done(function(data){ return data;});
runParallel ( ). done(function(data){ return data;});
runParallel () .then(data);
runParallel () .then(data);
runParallel () .then(function(data) return data
runParallel () .then(function(data) return data
Suggested answer: B, D
asked 23/09/2024
Vito Ranieri
44 questions

Question 2

Report Export Collapse

A developer needs to test this function:

01 const sum3 = (arr) => (

02 if (!arr.length) return 0,

03 if (arr.length === 1) return arr[0],

04 if (arr.length === 2) return arr[0] + arr[1],

05 return arr[0] + arr[1] + arr[2],

06 );

Which two assert statements are valid tests for the function?

Choose 2 answers

console.assert(sum3(1, '2')) == 12);
console.assert(sum3(1, '2')) == 12);
console.assert(sum3(0)) == 0);
console.assert(sum3(0)) == 0);
console.assert(sum3(-3, 2 )) == -1);
console.assert(sum3(-3, 2 )) == -1);
console.assert(sum3('hello', 2, 3, 4)) === NaN);
console.assert(sum3('hello', 2, 3, 4)) === NaN);
Suggested answer: A, C
asked 23/09/2024
Mitesh Patel
32 questions

Question 3

Report Export Collapse

Which statement phrases successfully?

JSON.parse ( ' foo ' );
JSON.parse ( ' foo ' );
JSON.parse ( " foo " );
JSON.parse ( " foo " );
JSON.parse( " ' foo ' " );
JSON.parse( " ' foo ' " );
JSON.parse(' " foo " ');
JSON.parse(' " foo " ');
Suggested answer: D
asked 23/09/2024
Pawel Lenart
34 questions

Question 4

Report Export Collapse

Refer to the code below:

01 let car1 = new promise((_, reject) =>

02 setTimeout(reject, 2000, "Car 1 crashed in"));

03 let car2 = new Promise(resolve => setTimeout(resolve, 1500, "Car 2 completed")); 04 let car3 = new Promise(resolve => setTimeout (resolve, 3000, "Car 3 Completed")); 05 Promise.race([car1, car2, car3]) 06 .then(value => ( 07 let

result = $(value) the race. `; 08 )) 09 .catch( arr => ( 10 console.log("Race is cancelled.", err); 11 )); What is the value of result when Promise.race executes?

Car 3 completed the race.
Car 3 completed the race.
Car 1 crashed in the race.
Car 1 crashed in the race.
Car 2 completed the race.
Car 2 completed the race.
Race is cancelled.
Race is cancelled.
Suggested answer: C
asked 23/09/2024
samer salami
34 questions

Question 5

Report Export Collapse

Refer to the code below: for(let number =2 ; number <= 5 ; number += 1 ) {

// insert code statement here

}

The developer needs to insert a code statement in the location shown. The code statement has these requirements:

Does require an import
Does require an import
Logs an error when the boolean statement evaluates to false
Logs an error when the boolean statement evaluates to false
Works in both the browser and Node.jsWhich meet the requirements?
Works in both the browser and Node.jsWhich meet the requirements?
assert (number % 2 === 0);
assert (number % 2 === 0);
console.error(number % 2 === 0);
console.error(number % 2 === 0);
console.debug(number % 2 === 0);
console.debug(number % 2 === 0);
console.assert(number % 2 === 0);
console.assert(number % 2 === 0);
Suggested answer: B
asked 23/09/2024
carlos miyares
22 questions

Question 6

Report Export Collapse

A developer is working on an ecommerce website where the delivery date is dynamically calculated based on the current day. The code line below is responsible for this calculation.

Const deliveryDate = new Date ();

Due to changes in the business requirements, the delivery date must now be today's date + 9 days.

Which code meets this new requirement?

deliveryDate.setDate(( new Date ( )).getDate () +9);
deliveryDate.setDate(( new Date ( )).getDate () +9);
deliveryDate.setDate( Date.current () + 9);
deliveryDate.setDate( Date.current () + 9);
deliveryDate.date = new Date(+9) ;
deliveryDate.date = new Date(+9) ;
deliveryDate.date = Date.current () + 9;
deliveryDate.date = Date.current () + 9;
Suggested answer: A
asked 23/09/2024
Maria Lilian Tongson
41 questions

Question 7

Report Export Collapse

Which three statements are true about promises ?

Choose 3 answers

The executor of a new Promise runs automatically.
The executor of a new Promise runs automatically.
A Promise has a .then() method.
A Promise has a .then() method.
A fulfilled or rejected promise will not change states .
A fulfilled or rejected promise will not change states .
A settled promise can become resolved.
A settled promise can become resolved.
A pending promise can become fulfilled, settled, or rejected.
A pending promise can become fulfilled, settled, or rejected.
Suggested answer: B, C, E
asked 23/09/2024
Serhan Azdiken
42 questions

Question 8

Report Export Collapse

Given the code below:

01 function GameConsole (name) {

02 this.name = name;

03 }

04

05 GameConsole.prototype.load = function(gamename) {

06 console.log( ` $(this.name) is loading a game : $(gamename) …`);

07 )

08 function Console 16 Bit (name) {

09 GameConsole.call(this, name) ;

10 }

11 Console16bit.prototype = Object.create ( GameConsole.prototype) ;

12 //insert code here

13 console.log( ` $(this.name) is loading a cartridge game : $(gamename) …`); 14 } 15 const console16bit = new Console16bit(' SNEGeneziz '); 16 console16bit.load(' Super Nonic 3x Force '); What should a developer insert at line 15 to

output the following message using the method ?

> SNEGeneziz is loading a cartridge game: Super Monic 3x Force . . .

Console16bit.prototype.load(gamename) = function() {
Console16bit.prototype.load(gamename) = function() {
Console16bit.prototype.load = function(gamename) {
Console16bit.prototype.load = function(gamename) {
Console16bit = Object.create(GameConsole.prototype).load = function(gamename) {
Console16bit = Object.create(GameConsole.prototype).load = function(gamename) {
Console16bit.prototype.load(gamename) {
Console16bit.prototype.load(gamename) {
Suggested answer: B
asked 23/09/2024
Steve Jenkins-Thorkildson
39 questions

Question 9

Report Export Collapse

A developer has the following array of student test grades:

Let arr = [ 7, 8, 5, 8, 9 ];

The Teacher wants to double each score and then see an array of the students who scored more than 15 points.

How should the developer implement the request?

Let arr1 = arr.filter(( val) => ( return val > 15 )) .map (( num) => ( return num *2 ))
Let arr1 = arr.filter(( val) => ( return val > 15 )) .map (( num) => ( return num *2 ))
Let arr1 = arr.mapBy (( num) => ( return num *2 )) .filterBy (( val ) => return val > 15 )) ;
Let arr1 = arr.mapBy (( num) => ( return num *2 )) .filterBy (( val ) => return val > 15 )) ;
Let arr1 = arr.map((num) => num*2). Filter (( val) => val > 15);
Let arr1 = arr.map((num) => num*2). Filter (( val) => val > 15);
Let arr1 = arr.map((num) => ( num *2)).filterBy((val) => ( val >15 ));
Let arr1 = arr.map((num) => ( num *2)).filterBy((val) => ( val >15 ));
Suggested answer: C
asked 23/09/2024
Andrea Trivisonno
31 questions

Question 10

Report Export Collapse

A 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 needs to verify how many times the method was called and the arguments used each time.

Which two test approaches describe the requirement?

Choose 2 answers

Integration
Integration
Black box
Black box
White box
White box
Mocking
Mocking
Suggested answer: C, D
asked 23/09/2024
Wanicha Inburan
37 questions
Total 224 questions
Go to page: of 23
Search

Related questions