Winter Special Limited Time 65% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: geek65

JavaScript-Developer-I Salesforce Certified JavaScript Developer I (SU24) Questions and Answers

Questions 4

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?

Options:

A.

Let arr1 = arr.filter(( val) => ( return val > 15 )) .map (( num) => ( return num *2 ))

B.

Let arr1 = arr.mapBy (( num) => ( return num *2 )) .filterBy (( val ) => return val > 15 )) ;

C.

Let arr1 = arr.map((num) => num*2). Filter (( val) => val > 15);

D.

Let arr1 = arr.map((num) => ( num *2)).filterBy((val) => ( val >15 ));

Buy Now
Questions 5

The developer has a function that prints “Hello” to an input name. To test this, thedeveloper created a function that returns “World”. However the following snippet does not print “ Hello World”.

What can the developer do to change the code to print “Hello World” ?

Options:

A.

Change line 7 to ) () ;

B.

Change line 2 to console.log(‘Hello’ , name() );

C.

Change line 9 to sayHello(world) ();

D.

Change line 5 to function world ( ) {

Buy Now
Questions 6

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?

Options:

A.

Replace line 02 with return arr.map(( result, current) => (

B.

Replace line 04 with result = result +current;

C.

Replace line 03 with if(arr.length == 0 ) ( return 0; )

D.

Replace line 05 with return result;

Buy Now
Questions 7

Refer to the code below:

Function changeValue(obj) {

Obj.value = obj.value/2;

}

Const objA = (value: 10);

Const objB = objA;

changeValue(objB);

Const result = objA.value;

What is the value of result after the code executes?

Options:

A.

10

B.

Nan

C.

5

D.

Undefined

Buy Now
Questions 8

Refer to the code below?

Let searchString = ‘ look for this ’;

Which two options remove the whitespace from the beginning of searchString?

Choose 2 answers

Options:

A.

searchString.trimEnd();

B.

searchString.trimStart();

C.

trimStart(searchString);

D.

searchString.replace(/*\s\s*/, ‘’);

Buy Now
Questions 9

A team that works on a big project uses npm to deal with projects dependencies.

A developer added a dependency does not get downloaded when they execute npm

install.

Which two reasons could be possible explanations for this?

Choose 2 answers

Options:

A.

The developer missed the option --add when adding the dependency.

B.

The developer added the dependency as a dev dependency, and

NODE_ENV

Is set to production.

C.

The developer missed the option --save when adding the dependency.

D.

The developer added the dependency as a dev dependency, and

NODE_ENV is set to production.

Buy Now
Questions 10

Refer to the following object:

const cat ={

firstName: ‘Fancy’,

lastName: ‘ Whiskers’,

Get fullName() {

return this.firstName + ‘ ‘ + this.lastName;

}

};

How can a developer access the fullName property for cat?

Options:

A.

cat.fullName

B.

cat.fullName()

C.

cat.get.fullName

D.

cat.function.fullName()

Buy Now
Questions 11

Refer to the code below:

let car1 = new Promise((_ ,reject)=> setTimeout(reject,2000,"Car1 crashed in"));

let car2 = new Promise(resolve => setTimeout(resolve,1500,"Car2 completed"));

let car3 = new Promise(resolve => setTimeout(resolve,3000,"Car3 completed"));

Promise.race([car1,car2,car3])

.then(value=>{

let result = `${value} the race.`;

}).catch(err=>{

console.log('Race is cancelled.',err);

});

What is the value of result when promise.race execues?

Options:

A.

Car2 completed the race.

Buy Now
Questions 12

Which statement accurately describes an aspect of promises?

Options:

A.

Arguments for the callback function passed to .then() are optional.

B.

In a.then() function, returning results is not necessary since callbacks will catch the result of a previous promise.

C.

.then() cannot be added after a catch.

D.

.then() manipulates and returns the original promise.

Buy Now
Questions 13

Refer to the following array:

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

Which three options result in x evaluating as [3, 4, 5] ?

Choose 3 answers.

Options:

A.

Let x= arr.filter (( a) => (a<2));

B.

Let x= arr.splice(2,3);

C.

Let x= arr.slice(2);

D.

Let x= arr.filter((a) => ( return a>2 ));

E.

Let x = arr.slice(2,3);

Buy Now
Questions 14

A developer wrote 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 or 5.

Which two test cases will properly test scenarios for the fizzbuzz function?

Choose 2 answers

Options:

A.

let res = fizzbuzz(5);

console.assert ( res === ‘ ’ );

B.

let res = fizzbuzz(15);

console.assert ( res === ‘ fizzbuzz ’ )

C.

let res = fizzbuzz(Infinity);

console.assert ( res === ‘ ’ )

D.

let res = fizzbuzz(3);

console.assert ( res === ‘ buzz ’ )

Buy Now
Questions 15

A developer has the function, shown below, that is called when a page loads.

Where can the developer see the log statement after loading the page in the browser?

Options:

A.

On the browser JavaScript console

B.

On the terminal console running the web server

C.

In the browser performance tools log

D.

On the webpage console log

Buy Now
Questions 16

Refer to the code below:

Const resolveAfterMilliseconds = (ms) => Promise.resolve (

setTimeout (( => console.log(ms), ms ));

Const aPromise = await resolveAfterMilliseconds(500);

Const bPromise = await resolveAfterMilliseconds(500);

Await aPromise, wait bPromise;

What is the result of running line 05?

Options:

A.

aPromise and bPromise run sequentially.

B.

Neither aPromise or bPromise runs.

C.

aPromise and bPromise run in parallel.

D.

Only aPromise runs.

Buy Now
Questions 17

Which three options show valid methods for creating a fat arrow function?

Choose 3 answers

Options:

A.

x => ( console.log(‘ executed ’) ; )

B.

[ ] => ( console.log(‘ executed ’) ;)

C.

( ) => ( console.log(‘ executed ’) ;)

D.

X,y,z => ( console.log(‘ executed ’) ;)

E.

(x,y,z) => ( console.log(‘ executed ’) ;)

Buy Now
Questions 18

A class was written to represent items for purchase in an online store, and a second class

Representing items that are on sale at a discounted price. THe constructor sets the name to the

first value passed in. The pseudocode is below:

Class Item {

constructor(name, price) {

… // Constructor Implementation

}

}

Class SaleItem extends Item {

constructor (name, price, discount) {

...//Constructor Implementation

}

}

There is a new requirement for a developer to implement a description method that will return a

brief description for Item and SaleItem.

Let regItem =new Item(‘Scarf’, 55);

Let saleItem = new SaleItem(‘Shirt’ 80, -1);

Item.prototype.description = function () { return ‘This is a ’ + this.name;

console.log(regItem.description());

console.log(saleItem.description());

SaleItem.prototype.description = function () { return ‘This is a discounted ’ +

this.name; }

console.log(regItem.description());

console.log(saleItem.description());

What is the output when executing the code above ?

Options:

A.

This is a Scarf

Uncaught TypeError: saleItem.description is not a function

This is aScarf

This is a discounted Shirt

B.

This is a Scarf

This is a Shirt

This is a Scarf

This is a discounted Shirt

C.

This is a Scarf

This is a Shirt

This is a discounted Scarf

This is a discounted Shirt

D.

This is aScarf

Uncaught TypeError: saleItem.description is not a function

This is a Shirt

This is a did counted Shirt

Buy Now
Questions 19

developer publishes a new version of a package with new features that do not break

backward compatibility. The previous version number was 1.1.3.

Following semantic versioning format, what should the new package version number

be?

Options:

A.

2.0.0

B.

1.2.3

C.

1.1.4

D.

1.2.0

Buy Now
Questions 20

Teams at Universal Containers (UC) work on multiple JavaScript projects at the same time.

UC is thinking about reusability and how each team can benefit from the work of others.

Going open-source or public is not an option at this time.

Which option is available to UC with npm?

Options:

A.

Private packages can be scored, and scopes can be associated to a private

registries.

B.

Private registries are not supported by npm, but packages can be installed via URL.

C.

Private packages are not supported, but they can use another package manager like

yarn.

D.

Private registries are not supported by npm, but packages can be installed via git.

Buy Now
Questions 21

Refer to the expression below:

Let x = (‘1’ + 2) == (6 * 2);

How should this expression be modified to ensure that evaluates to false?

Options:

A.

Let x = (‘1’ + ‘ 2’) == ( 6 * 2);

B.

Let x = (‘1’ + 2) == ( 6 * 2);

C.

Let x = (1 + 2) == ( ‘6’ / 2);

D.

Let x = (1 + 2 ) == ( 6 / 2);

Buy Now
Questions 22

Refer to the code below:

function changeValue(param) {

Param =5;

}

Let a =10;

Let b =5;

changeValue(b);

Const result = a+ “ - ”+ b;

What is the value of result when code executes?

Options:

A.

10 -10

B.

5 -5

C.

5 - 10

D.

10 - 5

Buy Now
Questions 23

A developer implements a function that adds a few values.

Function sum(num) {

If (num == undefined) {

Num =0;

}

Return function( num2, num3){

If (num3 === undefined) {

Num3 =0 ;

}

Return num + num2 + num3;

}

}

Which three options can the developer invoke for this function to get a return value of 10 ?

Choose 3 answers

Options:

A.

Sum () (20)

B.

Sum (5, 5) ()

C.

sum() (5, 5)

D.

sum(5)(5)

E.

sum(10) ()

Buy Now
Questions 24

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

Options:

A.

console.assert(sum3(1, ‘2’)) == 12);

B.

console.assert(sum3(0)) == 0);

C.

console.assert(sum3(-3, 2 )) == -1);

D.

console.assert(sum3(‘hello’, 2, 3, 4)) === NaN);

Buy Now
Questions 25

Refer to the following code:

class Vehicle{

constructor(plate){

this.plate = plate;

}

}

class Truck extends Vehicle{

constructor(plate, weight){

//Missing code

this.weight = weight;

}

displayWeight(){

console.log(`The truck ${this.plate} has a weight of ${this.weight}lb.`);

}

}let myTruck = new Truck('123Ab',5000);

myTruck.displayWeight();

Which statement should be added to missing code for the code to display 'The truck 123AB has a

weight of 5000lb.

Options:

A.

super(plate)

B.

super.plate = plate

C.

Vehicle.plate = plate

D.

this.plate = plate

Buy Now
Questions 26

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?

Options:

A.

When rejected

B.

When resolved and settled

C.

When resolved

D.

When resolved or rejected

Buy Now
Questions 27

Refer to the following code:

Let obj ={

Foo: 1,

Bar: 2

}

Let output =[],

for(let something in obj{

output.push(something);

}

console.log(output);

What is the output line 11?

Options:

A.

[1,2]

B.

[“bar”,”foo”]

C.

[“foo”,”bar”]

D.

[“foo:1”,”bar:2”]

Buy Now
Questions 28

A developer is trying to handle an error within a function.

Which code segment shows the correct approach to handle an error without propagating it elsewhere?

A)

B)

C)

D)

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

Buy Now
Questions 29

A developer creates a generic function to log custom messages in the console. To do this,

the function below is implemented.

01 function logStatus(status){

02 console./*Answer goes here*/{‘Item status is: %s’, status};

03 }

Which three console logging methods allow the use of string substitution in line 02?

Options:

A.

Assert

B.

Log

C.

Message

D.

Info

E.

Error

Buy Now
Questions 30

Refer to the following code block:

What is the console output?

Options:

A.

> Better student Jackie got 70% on test.

B.

> Jackie got 70% on test.

C.

> Uncaught Reference Error

D.

> Better student Jackie got 100% on test.

Buy Now
Questions 31

is below:

”Image

The JavaScript portion is:

01 function previewFile(){

02 const preview = document.querySelector(‘img’);

03 const file = document.querySelector(‘input[type=file]’).files[0];

04 //line 4 code

05 reader.addEventListener(“load”, () => {

06 preview.src = reader.result;

07 },false);

08 //line 8 code

09 }

In lines 04 and 08, which code allows the user to select an image from their local

computer , and to display the image in the browser?

Options:

A.

04 const reader = new File();

08 if (file) URL.createObjectURL(file);

B.

04 const reader = new FileReader();

08 if (file) URL.createObjectURL(file);

C.

04 const reader = new File();

08 if (file) reader.readAsDataURL(file);

D.

04 const reader = new FileReader();

08 if (file) reader.readAsDataURL(file);

Buy Now
Questions 32

Given the following code:

document.body.addEventListener(‘ click ’, (event) => {

if (/* CODE REPLACEMENT HERE */) {

console.log(‘button clicked!’);

)

});

Which replacement for the conditional statement on line 02 allows a developer to

correctly determine that a button on page is clicked?

Options:

A.

Event.clicked

B.

e.nodeTarget ==this

C.

event.target.nodeName == ‘BUTTON’

D.

button.addEventListener(‘click’)

Buy Now
Questions 33

Refer to following code block:

Let array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,];

Let output =0;

For (let num of array){

if (output >0){

Break;

}

if(num % 2 == 0){

Continue;

}

Output +=num;

What is the value of output after the code executes?

Options:

A.

16

B.

36

C.

11

D.

25

Buy Now
Exam Name: Salesforce Certified JavaScript Developer I (SU24)
Last Update: Nov 21, 2024
Questions: 215
JavaScript-Developer-I pdf

JavaScript-Developer-I PDF

$28  $80
JavaScript-Developer-I Engine

JavaScript-Developer-I Testing Engine

$33.25  $95
JavaScript-Developer-I PDF + Engine

JavaScript-Developer-I PDF + Testing Engine

$45.5  $130