ExamGecko
Home Home / Salesforce / Certified JavaScript Developer I

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

Question list
Search
Search

List of questions

Search

Related questions











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?

A.
Replace line 02 with return arr.map(( result, current) => (
A.
Replace line 02 with return arr.map(( result, current) => (
Answers
B.
Replace line 04 with result = result +current;
B.
Replace line 04 with result = result +current;
Answers
C.
Replace line 03 with if(arr.length == 0 ) ( return 0; )
C.
Replace line 03 with if(arr.length == 0 ) ( return 0; )
Answers
D.
Replace line 05 with return result;
D.
Replace line 05 with return result;
Answers
Suggested answer: D

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

A.
0); console.log(2); New Promise ((resolve, reject )) = > ( setTimeout(() => ( reject(console.log(3));
A.
0); console.log(2); New Promise ((resolve, reject )) = > ( setTimeout(() => ( reject(console.log(3));
Answers
B.
1000);)).catch(() => ( console.log(4); )); console.log(5); What is logged to the console?
B.
1000);)).catch(() => ( console.log(4); )); console.log(5); What is logged to the console?
Answers
C.
2 1 4 3 5
C.
2 1 4 3 5
Answers
D.
2 5 1 3 4
D.
2 5 1 3 4
Answers
E.
1 2 4 3 5
E.
1 2 4 3 5
Answers
F.
1 2 5 3 4
F.
1 2 5 3 4
Answers
Suggested answer: B

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

A.
The associated class contains some asynchronous functions.
A.
The associated class contains some asynchronous functions.
Answers
B.
The associated function will always return a promise
B.
The associated function will always return a promise
Answers
C.
The associated function can only be called via asynchronous methods
C.
The associated function can only be called via asynchronous methods
Answers
D.
The associated sometimes returns a promise.
D.
The associated sometimes returns a promise.
Answers
Suggested answer: B

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 ?

A.
node -i index.js
A.
node -i index.js
Answers
B.
Node --inspect-brk index.js
B.
Node --inspect-brk index.js
Answers
C.
Node inspect index.js
C.
Node inspect index.js
Answers
D.
Node --inspect index.js
D.
Node --inspect index.js
Answers
Suggested answer: D

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?

A.
Console.assert (await functionUnderTest(true), ' OK ')
A.
Console.assert (await functionUnderTest(true), ' OK ')
Answers
B.
Console.assert (await functionUnderTest(true), ' not OK ')
B.
Console.assert (await functionUnderTest(true), ' not OK ')
Answers
C.
Console.assert (await functionUnderTest(true), ' not OK ')
C.
Console.assert (await functionUnderTest(true), ' not OK ')
Answers
D.
Console.assert (await functionUnderTest(true), 'OK')
D.
Console.assert (await functionUnderTest(true), 'OK')
Answers
Suggested answer: D

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

True + 3 + '100' + null

A.
104
A.
104
Answers
B.
4100
B.
4100
Answers
C.
'3100null'
C.
'3100null'
Answers
D.
'4100null'
D.
'4100null'
Answers
Suggested answer: D

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.
A.
The line 02 assertion passes.
Answers
B.
The line 02 assertion fails
B.
The line 02 assertion fails
Answers
C.
The line 05 assertion passes.
C.
The line 05 assertion passes.
Answers
D.
The line 05 assertion fails.
D.
The line 05 assertion fails.
Answers
Suggested answer: A, D

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?

A.
Replace line 04 with console.log(input .value);
A.
Replace line 04 with console.log(input .value);
Answers
B.
Replace line 03 with const input = document.getElementByName('input');
B.
Replace line 03 with const input = document.getElementByName('input');
Answers
C.
Replace line 02 with button.addEventListener("onclick", function() {
C.
Replace line 02 with button.addEventListener("onclick", function() {
Answers
D.
Replace line 02 with button.addCallback("click", function() {
D.
Replace line 02 with button.addCallback("click", function() {
Answers
Suggested answer: A

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 ?

A.
Object.const()
A.
Object.const()
Answers
B.
Object.eval()
B.
Object.eval()
Answers
C.
Object.lock()
C.
Object.lock()
Answers
D.
Object.freeze()
D.
Object.freeze()
Answers
Suggested answer: D

A developer has an ErrorHandler module that contains multiple functions.

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

A.
Named
A.
Named
Answers
B.
All
B.
All
Answers
C.
Multi
C.
Multi
Answers
D.
Default
D.
Default
Answers
Suggested answer: A
Total 224 questions
Go to page: of 23