Labour Day Special - Limited Time 65% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: top65certs

Salesforce JavaScript-Developer-I Dumps

Salesforce Certified JavaScript Developer I (SP23) Questions and Answers

Question 1

Given the JavaScript below:

01 function filterDOM (searchString) {

02 const parsedSearchString = searchString && searchString.toLowerCase() ;

03 document.quesrySelectorAll(‘ .account’ ) . forEach(account => (

04 const accountName = account.innerHTML.toLOwerCase();

05 account. Style.display = accountName.includes(parsedSearchString) ? /*Insert

code*/;

06 )};

07 }

Which code should replace the placeholder comment on line 05 to hide accounts that do

not match the search string?

Options:

A.

‘ name ’ : ‘ block ’

B.

‘ Block ’ : ‘ none ’

C.

‘ visible ’ : ‘ hidden ’

D.

‘ hidden ’ : ‘ visible ’

Question 2

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

Options:

A.

Async runParallel () .then(data);

B.

runParallel ( ). done(function(data){

return data;

});

C.

runParallel () .then(data);

D.

runParallel () .then(function(data)

return data

Question 3

Refer to the HTML below:

Which JavaScript statement results in changing “ The Lion.”?

Options:

A.

document.querySelectorAll(‘$main $TONY’).innerHTML = ’“ The Lion

B.

document.querySelector(‘$main li:second-child’).innerHTML = “ The Lion ’;

C.

document.querySelector(‘$main li.Tony’).innerHTML = ’“ The Lion ’;

D.

document.querySelector(‘$main li:nth-child(2)’),innerHTML = “ The Lion. ’;

Question 4

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’)

Question 5

Which code statement below correctly persists an objects in local Storage ?

Options:

A.

const setLocalStorage = (storageKey, jsObject) => {

window.localStorage.setItem(storageKey, JSON.stringify(jsObject));

}

B.

const setLocalStorage = ( jsObject) => {

window.localStorage.connectObject(jsObject));

}

C.

const setLocalStorage = ( jsObject) => {

window.localStorage.setItem(jsObject);

}

D.

const setLocalStorage = (storageKey, jsObject) => {

window.localStorage.persist(storageKey, jsObject);

}

Question 6

Given the code below:

What is logged to the console'

Options:

A.

1 2 3 4 5

B.

1 2 5 3 4

C.

2 5 1 3 4

D.

2 5 3 4 1

Question 7

Refer to HTML below:

This card is smaller.

The width and height of this card is determined by its

contents.

Which expression outputs the screen width of the element with the ID card-01?

Options:

A.

document.getElementById(‘ card-01 ’).getBoundingClientRest().width

B.

document.getElementById(‘ card-01 ’).style.width

C.

document.getElementById(‘ card-01 ’).width

D.

document.getElementById(‘ card-01 ’).innerHTML.lenght*e

Question 8

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

Question 9

A developer is wondering whether to use, Promise.then or Promise.catch, especially

when a Promise throws an error?

Which two promises are rejected?

Which 2 are correct?

Options:

A.

Promise.reject(‘cool error here’).then(error => console.error(error));

B.

Promise.reject(‘cool error here’).catch(error => console.error(error));

C.

New Promise((resolve, reject) => (throw ‘cool error here’}).catch(error =>

console.error(error)) ;

D.

New Promise(() => (throw ‘cool error here’}).then(null, error => console.error(error)));

Question 10

A developer at Universal Containers creates a new landing page based on HTML, CSS, and

JavaScript TO ensure that visitors have a good experience, a script named personaliseContext

needs to be executed when the webpage is fully loaded (HTML content and all related files ), in

order to do some custom initialization.

Which statement should be used to call personalizeWebsiteContent based on the above

business requirement?

Options:

A.

document.addEventListener(‘’onDOMContextLoaded’, personalizeWebsiteContext);

B.

window.addEventListener(‘load’,personalizeWebsiteContext);

C.

window.addEventListener(‘onload’, personalizeWebsiteContext);

D.

Document.addEventListener(‘‘’DOMContextLoaded’ , personalizeWebsiteContext);

Question 11

Given the following code:

What is the output of line 02?

Options:

A.

"null"

B.

"x-

C.

"undefined" 0

D.

'object"

Question 12

A developer implements and calls the following code when an application state change occurs:

Const onStateChange =innerPageState) => {

window.history.pushState(newPageState, ‘ ’, null);

}

If the back button is clicked after this method is executed, what can a developer expect?

Options:

A.

A navigate event is fired with a state property that details the previous application state.

B.

The page is navigated away from and the previous page in the browser’s history is loaded.

C.

The page reloads and all Javascript is reinitialized.

D.

A popstate event is fired with a state property that details the application’s last state.

Question 13

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

Question 14

Refer to the code below:

const car = {

price:100,

getPrice:function(){

return this.price;

}

};

const customCar = Object.create(car);

customCar.price = 70;

delete customCar.price;const result = customCar.getPrice();

What is the value of result after the code executes?

Options:

A.

100

B.

undefined

C.

null

D.

70

Question 15

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 numbers in the array, and the test passes.

A different developer made changes to the behavior of sum3 to instead sum only the first two numbers present in the array.

Which two results occur when running this test on the updated sum3 function?

Choose 2 answers

Options:

A.

The line 05 assertion passes.

B.

The line 02 assertion passes.

C.

The line 02 assertion fails.

D.

The line 05 assertion fails.

Question 16

In the browser, the window object is often used to assign variables that require the broadest scope in an application Node.js application does not have access to the window object by default.

Which two methods are used to address this ?

Choose 2 answers

Options:

A.

Use the document object instead of the window object.

B.

Assign variables to the global object.

C.

Create a new window object in the root file.

D.

Assign variables to module.exports and require them as needed.

Question 17

Given the code below:

Which method can be used to provide a visual representation of the list of users and to allow sorting by the name or email attribute?

Options:

A.

console.group(usersList) ;

B.

console.table(usersList) ;

C.

console.info(usersList) ;

D.

console.groupCol lapsed (usersList) ;

Question 18

A developer wants to iterate through an array of objects and count the objects and count

the objects whose property value, name, starts with the letter N.

Const arrObj = [{“name” : “Zach”} , {“name” : “Kate”},{“name” : “Alise”},{“name” : “Bob”},{“name” :

“Natham”},{“name” : “nathaniel”}

Refer to the code snippet below:

01 arrObj.reduce(( acc, curr) => {

02 //missing line 02

02 //missing line 03

04 ). 0);

Which missing lines 02 and 03 return the correct count?

Options:

A.

Const sum = curr.startsWith(‘N’) ? 1: 0;

Return acc +sum

B.

Const sum = curr.name.startsWith(‘N’) ? 1: 0;

Return acc +sum

C.

Const sum = curr.startsWIth(‘N’) ? 1: 0;

Return curr+ sum

D.

Const sum = curr.name.startsWIth(‘N’) ? 1: 0;

Return curr+ sum

Question 19

A developer is setting up a Node,js server and is creating a script at the root of the source code, index,js, that will start the server when executed. The developer declares a variable that needs the folder location that the code executes from.

Which global variable can be used in the script?

Options:

A.

window.location

B.

_filename

C.

_dirname

D.

this.path

Question 20

Given the following code:

Let x =null;

console.log(typeof x);

What is the output of the line 02?

Options:

A.

“Null”

B.

“X”

C.

“Object”

D.

“undefined”

Question 21

A developer is leading the creation of a new browser application that will serve a single

page application. The team wants to use a new web framework Minimalsit.js. The Lead

developer wants to advocate for a more seasoned web framework that already has a

community around it.

Which two frameworks should the lead developer advocate for?

Choose 2 answers

Options:

A.

Vue

B.

Angular

C.

Koa

D.

Express

Question 22

A test has a dependency on database. query. During the test, the dependency is replaced with an object called database with the method,

Calculator query, that returns an array. The developer does not need to verify how many times the method has been called.

Which two test approaches describe the requirement?

Choose 2 answers

Options:

A.

White box

B.

Stubbing

C.

Black box

D.

Substitution

Question 23

Refer to the following code:

What is the value of output on line 11?

Options:

A.

[1, 2]

B.

[‘’foo’’, ‘’bar’’]

C.

[‘’foo’’:1, ‘’bar’’:2’’]

D.

An error will occur due to the incorrect usage of the for…of statement on line 07.

Question 24

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 ( ) {

Question 25

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 ?

Options:

A.

Object.const()

B.

Object.eval()

C.

Object.lock()

D.

Object.freeze()

Question 26

A developer has an ErrorHandler module that contains multiple functions.

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

Options:

A.

all

B.

named

C.

multi

D.

default

Question 27

Refer to code below:

Let a =’a’;

Let b;

// b = a;

console.log(b);

What is displayed when the code executes?

Options:

A.

ReferenceError: b is not defined

B.

A

C.

Undefined

D.

Null

Question 28

A developer writes the code below to return a message to a user attempting to register a new username. If the username is available, a variable named nag is declared and assigned a value on line 03.

What is the value of msg when getAvailableabilityMessage (“newUserName”) is executed and get Availability (“newUserName”) returns true?

Options:

A.

"msg is not defined"

B.

"newUserName"

C.

"User-name available"

D.

undefined

Question 29

Refer to the following code:

Let sampleText = ‘The quick brown fox jumps’;

A developer needs to determine if a certain substring is part of a string.

Which three expressions return true for the given substring ?

Choose 3 answers

Options:

A.

sampleText.includes(‘fox’);

B.

sampleText.includes(‘ quick ’, 4);

C.

sampleText.includes(‘ Fox ’, 3)

D.

sampleText.includes(‘ fox ’);

E.

sampleText.includes(‘ quick ’) !== -1;

Question 30

Cloud Kicks has a class to represent items for sale in an online store, as shown below:

Class Item{

constructor (name, price){

this.name = name;

this.price = price;

}

formattedPrice(){

return ‘s’ + String(this.price);}}

A new business requirement comes in that requests a ClothingItem class that should have all of

the properties and methods of the Item class but will also have properties that are specific to

clothes.

Which line of code properly declares the clothingItem class such that it inherits from

Item?

Options:

A.

Class ClothingItem implements Item{

B.

Class ClothingItem {

C.

Class ClothingItem super Item {

D.

Class ClothingItem extends Item {

Question 31

developer creates a new web server that uses Node.js. It imports a server library that

uses events and callbacks for handling server functionality.

The server library is imported with require and is made available to the code by a

variable named server. The developer wants to log any issues that the server has while booting

up.

Given the code and the information the developer has, which code logs an error at boost

with an event?

Options:

A.

Server.catch ((server) => {

console.log(‘ERROR’, error);

});

B.

Server.error ((server) => {

console.log(‘ERROR’, error);

});

C.

Server.on (‘error’, (error) => {

console.log(‘ERROR’, error);

});

D.

Try{

server.start();

} catch(error) {

console.log(‘ERROR’, error);

}

Question 32

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

Options:

A.

Integration

B.

Black box

C.

White box

D.

Mocking

Question 33

Given the following code:

is the output of line 02?

Options:

A.

''x''

B.

''null'''

C.

''object''

D.

''undefined''