ExamGecko
Home Home / Salesforce / Certified JavaScript Developer I

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

Question list
Search
Search

List of questions

Search

Related questions











Refer to the code below:

Line 05 causes an error.

What are the values of greeting and salutation once code completes?

A.
Greeting is Hello and salutation is Hello, Hello.
A.
Greeting is Hello and salutation is Hello, Hello.
Answers
B.
Greeting is Goodbye and salutation is Hello, Hello.
B.
Greeting is Goodbye and salutation is Hello, Hello.
Answers
C.
Greeting is Goodbye and salutation is I say Hello.
C.
Greeting is Goodbye and salutation is I say Hello.
Answers
D.
Greeting is Hello and salutation is I say hello.
D.
Greeting is Hello and salutation is I say hello.
Answers
Suggested answer: A

Refer to the code below:

Let str = 'javascript';

Str[0] = 'J';

Str[4] = 'S';

After changing the string index values, the value of str is 'javascript'. What is the reason for this value:

A.
Non-primitive values are mutable.
A.
Non-primitive values are mutable.
Answers
B.
Non-primitive values are immutable.
B.
Non-primitive values are immutable.
Answers
C.
Primitive values are mutable.
C.
Primitive values are mutable.
Answers
D.
Primitive values are immutable.
D.
Primitive values are immutable.
Answers
Suggested answer: D

Refer to the code below:

new Promise((resolve, reject) => {

const fraction = Math.random();

if( fraction >0.5) reject("fraction > 0.5, " + fraction);

resolve(fraction);

})

.then(() =>console.log("resolved"))

.catch((error) => console.error(error))

.finally(() => console.log(" when am I called?"));

When does Promise.finally on line 08 get called?

A.
When rejected
A.
When rejected
Answers
B.
When resolved and settled
B.
When resolved and settled
Answers
C.
When resolved
C.
When resolved
Answers
D.
When resolved or rejected
D.
When resolved or rejected
Answers
Suggested answer: D

Refer to the following array:

Let arr1 = [ 1, 2, 3, 4, 5 ];

Which two lines of code result in a second array, arr2 being created such that arr2 is not a reference to arr1?

A.
Let arr2 = arr1.slice(0, 5);
A.
Let arr2 = arr1.slice(0, 5);
Answers
B.
Let arr2 = Array.from(arr1);
B.
Let arr2 = Array.from(arr1);
Answers
C.
Let arr2 = arr1;
C.
Let arr2 = arr1;
Answers
D.
Let arr2 = arr1.sort();
D.
Let arr2 = arr1.sort();
Answers
Suggested answer: A, B

Refer to code below:

Function muFunction(reassign){ Let x = 1; var y = 1; if( reassign ) { Let x= 2; Var y = 2; console.log(x); console.log(y);} console.log(x); console.log(y);} What is displayed when myFunction(true) is called?

A.
2 2 1 1
A.
2 2 1 1
Answers
B.
2 2 undefined undefined
B.
2 2 undefined undefined
Answers
C.
2 2 1 2
C.
2 2 1 2
Answers
D.
2 2 2 2
D.
2 2 2 2
Answers
Suggested answer: C

A developer wants to create an object from a function in the browser using the code below:

Function Monster() { this.name = 'hello' };

Const z = Monster();

What happens due to lack of the new keyword on line 02?

A.
The z variable is assigned the correct object.
A.
The z variable is assigned the correct object.
Answers
B.
The z variable is assigned the correct object but this.name remains undefined.
B.
The z variable is assigned the correct object but this.name remains undefined.
Answers
C.
Window.name is assigned to 'hello' and the variable z remains undefined.
C.
Window.name is assigned to 'hello' and the variable z remains undefined.
Answers
D.
Window.m is assigned the correct object.
D.
Window.m is assigned the correct object.
Answers
Suggested answer: C

developer removes the HTML class attribute from the checkout button, so now it is simply:

<button>Checkout</button>.

There is a test to verify the existence of the checkout button, however it looks for a button with class= "blue". The test fails because no such button is found.

Which type of test category describes this test?

A.
True positive
A.
True positive
Answers
B.
True negative
B.
True negative
Answers
C.
False positive
C.
False positive
Answers
D.
False negative
D.
False negative
Answers
Suggested answer: D

Which two code snippets show working examples of a recursive function?

Choose 2 answers

A.
Let countingDown = function(startNumber) {If ( startNumber >0) {console.log(startNumber) ;return countingDown(startNUmber);} else {return startNumber;}};
A.
Let countingDown = function(startNumber) {If ( startNumber >0) {console.log(startNumber) ;return countingDown(startNUmber);} else {return startNumber;}};
Answers
B.
Function factorial ( numVar ) {If (numVar < 0) return;If ( numVar === 0 ) return 1;return numVar -1;
B.
Function factorial ( numVar ) {If (numVar < 0) return;If ( numVar === 0 ) return 1;return numVar -1;
Answers
C.
Const sumToTen = numVar => {If (numVar < 0)Return;return sumToTen(numVar + 1)};
C.
Const sumToTen = numVar => {If (numVar < 0)Return;return sumToTen(numVar + 1)};
Answers
D.
Const factorial =numVar => {If (numVar < 0) return;If ( numVar === 0 ) return 1;return numVar * factorial ( numVar - 1 );};
D.
Const factorial =numVar => {If (numVar < 0) return;If ( numVar === 0 ) return 1;return numVar * factorial ( numVar - 1 );};
Answers
Suggested answer: A, D

Refer to the HTML below:

<div id="main">

<ul>

<li>Leo</li>

<li>Tony</li>

<li>Tiger</li>

</ul>

</div>

Which JavaScript statement results in changing " Tony" to "Mr. T."?

A.
document.querySelectorAll('$main ONY').innerHTML = ' Mr. T. ';
A.
document.querySelectorAll('$main ONY').innerHTML = ' Mr. T. ';
Answers
B.
document.querySelector('$main li:second-child').innerHTML = ' Mr. T. ';
B.
document.querySelector('$main li:second-child').innerHTML = ' Mr. T. ';
Answers
C.
document.querySelector('$main li.Tony').innerHTML = ' Mr. T. ';
C.
document.querySelector('$main li.Tony').innerHTML = ' Mr. T. ';
Answers
D.
document.querySelector('$main li:nth-child(2)'),innerHTML = ' Mr. T. ';
D.
document.querySelector('$main li:nth-child(2)'),innerHTML = ' Mr. T. ';
Answers
Suggested answer: D

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

True + '13' + NaN

A.
' 113Nan '
A.
' 113Nan '
Answers
B.
14
B.
14
Answers
C.
' true13 '
C.
' true13 '
Answers
D.
' true13NaN '
D.
' true13NaN '
Answers
Suggested answer: D
Total 224 questions
Go to page: of 23