ExamGecko
Ask Question

Salesforce Certified JavaScript Developer I Practice Test - Questions Answers, Page 3

Add to Whishlist

List of questions

Question 21

Report Export Collapse

A developer is required to write a function that calculates the sum of elements in an array but is getting undefined every time the code is executed. The developer needs to find what is missing in the code below.

Const sumFunction = arr => {

Return arr.reduce((result, current) => {

//

Result += current;

//

), 10);

);Which option makes the code work as expected?

Replace line 02 with return arr.map(( result, current) => (
Replace line 02 with return arr.map(( result, current) => (
Replace line 04 with result = result +current;
Replace line 04 with result = result +current;
Replace line 03 with if(arr.length == 0 ) ( return 0; )
Replace line 03 with if(arr.length == 0 ) ( return 0; )
Replace line 05 with return result;
Replace line 05 with return result;
Suggested answer: D
asked 23/09/2024
Karsten Heimers
45 questions

Question 22

Report Export Collapse

Given code below: setTimeout (() => ( console.log(1);

0); console.log(2); New Promise ((resolve, reject )) = > ( setTimeout(() => ( reject(console.log(3));
0); console.log(2); New Promise ((resolve, reject )) = > ( setTimeout(() => ( reject(console.log(3));
1000);)).catch(() => ( console.log(4); )); console.log(5); What is logged to the console?
1000);)).catch(() => ( console.log(4); )); console.log(5); What is logged to the console?
2 1 4 3 5
2 1 4 3 5
2 5 1 3 4
2 5 1 3 4
1 2 4 3 5
1 2 4 3 5
1 2 5 3 4
1 2 5 3 4
Suggested answer: B
asked 23/09/2024
Anthony Wilson
44 questions

Question 23

Report Export Collapse

Which statement accurately describes the behaviour of the async/ await keyworks ?

The associated class contains some asynchronous functions.
The associated class contains some asynchronous functions.
The associated function will always return a promise
The associated function will always return a promise
The associated function can only be called via asynchronous methods
The associated function can only be called via asynchronous methods
The associated sometimes returns a promise.
The associated sometimes returns a promise.
Suggested answer: B
asked 23/09/2024
Ahmed Khan
51 questions

Question 24

Report Export Collapse

A developer is debugging a web server that uses Node.js The server hits a runtimeerror every third request to an important endpoint on the web server.

The developer added a break point to the start script, that is at index.js at he root of the server's source code. The developer wants to make use of chrome DevTools to debug.

Which command can be run to access DevTools and make sure the breakdown is hit ?

node -i index.js
node -i index.js
Node --inspect-brk index.js
Node --inspect-brk index.js
Node inspect index.js
Node inspect index.js
Node --inspect index.js
Node --inspect index.js
Suggested answer: D
asked 23/09/2024
Franklin Leon
45 questions

Question 25

Report Export Collapse

Refer to the code below:

Async funct on functionUnderTest(isOK) {

If (isOK) return 'OK' ;

Throw new Error('not OK');

)

Which assertion accurately tests the above code?

Console.assert (await functionUnderTest(true), ' OK ')
Console.assert (await functionUnderTest(true), ' OK ')
Console.assert (await functionUnderTest(true), ' not OK ')
Console.assert (await functionUnderTest(true), ' not OK ')
Console.assert (await functionUnderTest(true), ' not OK ')
Console.assert (await functionUnderTest(true), ' not OK ')
Console.assert (await functionUnderTest(true), 'OK')
Console.assert (await functionUnderTest(true), 'OK')
Suggested answer: D
asked 23/09/2024
Nivi Kolatte
46 questions

Question 26

Report Export Collapse

Consider type coercion, what does the following expression evaluate to?

True + 3 + '100' + null

104
104
4100
4100
'3100null'
'3100null'
'4100null'
'4100null'
Suggested answer: D
asked 23/09/2024
Michael Bays
42 questions

Question 27

Report Export Collapse

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

The line 02 assertion passes.
The line 02 assertion passes.
The line 02 assertion fails
The line 02 assertion fails
The line 05 assertion passes.
The line 05 assertion passes.
The line 05 assertion fails.
The line 05 assertion fails.
Suggested answer: A, D
asked 23/09/2024
wietse Bonnes
46 questions

Question 28

Report Export Collapse

A developer creates a simple webpage with an input field. When a user enters text in the input field and clicks the button, the actual value of the field must be displayed in the console.

Here is the HTML file content:

<input type =" text" value="Hello" name ="input">

<button type ="button" >Display </button>

The developer wrote the javascript code below:

Const button = document.querySelector('button'); button.addEvenListener('click', () => ( Const input = document.querySelector('input'); console.log(input.getAttribute('value')); When the user clicks the button, the output is always "Hello".

What needs to be done make this code work as expected?

Replace line 04 with console.log(input .value);
Replace line 04 with console.log(input .value);
Replace line 03 with const input = document.getElementByName('input');
Replace line 03 with const input = document.getElementByName('input');
Replace line 02 with button.addEventListener("onclick", function() {
Replace line 02 with button.addEventListener("onclick", function() {
Replace line 02 with button.addCallback("click", function() {
Replace line 02 with button.addCallback("click", function() {
Suggested answer: A
asked 23/09/2024
Vilfride Lutumba
45 questions

Question 29

Report Export Collapse

A developer creates an object where its properties should be immutable and prevent properties from being added or modified.

Which method should be used to execute this business requirement ?

Object.const()
Object.const()
Object.eval()
Object.eval()
Object.lock()
Object.lock()
Object.freeze()
Object.freeze()
Suggested answer: D
asked 23/09/2024
Mariusz Szczubelek
43 questions

Question 30

Report Export Collapse

A developer has an ErrorHandler module that contains multiple functions.

What kind of export be leverages so that multiple functions can be used?

Named
Named
All
All
Multi
Multi
Default
Default
Suggested answer: A
asked 23/09/2024
Volkan Ozsoy
40 questions
Total 224 questions
Go to page: of 23
Search

Related questions