11.11 Special Limited Time Flat 70% Discount offer - Ends in 0d 00h 00m 00s - Coupon code: 70spcl

Salesforce JavaScript-Developer-I Salesforce Certified JavaScript Developer I (SU24) Exam Practice Test

Page: 1 / 22
Total 215 questions

Salesforce Certified JavaScript Developer I (SU24) Questions and Answers

Question 1

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?

Options:

A.

Replace line 04 with console.log(input .value);

B.

Replace line 03 with const input = document.getElementByName(‘input’);

C.

Replace line 02 with button.addEventListener(“onclick”, function() {

D.

Replace line 02 with button.addCallback(“click”, function() {

Question 2

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

Question 3

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 4

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

Question 5

Refer to the following code:

function test (val) {

If (val === undefined) {

return ‘Undefined values!’ ;

}

if (val === null) {

return ‘Null value! ’;

}

return val;

}

Let x;

test(x);

What is returned by the function call on line 13?

Options:

A.

Undefined

B.

Line 13 throws an error.

C.

‘Undefined values!’

D.

‘Null value!’

Question 6

At Universal Containers, every team has its own way of copying JavaScript objects. The code snippet shows an Implementation from one team:

Question # 6

What is the output of the code execution?

Options:

A.

Hello John Doe

B.

Hello Dan

C.

Hello Dan Doe

D.

SyntaxError: Unexpected token in JSON

Question 7

A developer has two ways to write a function:

Option A:

function Monster(){

this.growl = ()=>{

console.log('Grr!');

}

}

Option B:

function Monster(){};

Monster.prototype.growl = ()=>{

console.log('Grr!');

}

After deciding on an option, the developer creates 1000 monster objects.

How many growl methods are created with Option A and Option B?

Options:

A.

1000 for Option A, 1 for Option B

B.

1 methods for both

C.

1000 for both

D.

1 for Option A, 1000 for Option B

Question 8

Given the code below:

Which three code segments result in a correct conversion from number to string? Choose 3 answers

Options:

A.

let strValue = numValue. toString();

B.

let strValue = * * 4 numValue;

C.

let strValue = numValue.toText ();

D.

let scrValue = String(numValue);

E.

let strValue = (String)numValue;

Question 9

Universal Containers recently launched its new landing page to host a crowd-funding

campaign. The page uses an external library to display some third-party ads. Once the page is

fully loaded, it creates more than 50 new HTML items placed randomly inside the DOM, like the

one in the code below:

Question # 9

All the elements includes the same ad-library-item class, They are hidden by default, and they are randomly displayed while the user navigates through the page.

Options:

A.

Use the DOM inspector to prevent the load event to be fired.

B.

Use the browser to execute a script that removes all the element containing the class ad-library-item.

C.

Use the DOM inspector to remove all the elements containing the class ad-library-item.

D.

Use the browser console to execute a script that prevents the load event to be fired.

Question 10

A developer writes the code below to calculate the factorial of a given number

function sum(number){

return number * sum(number-1);

}

sum(3);

what is the result of executing the code.

Options:

A.

0

B.

6

C.

Error

D.

-Infinity

Question 11

Given the JavaScript below:

Question # 11

Which code should replace the placeholder comment on line 06 to hide accounts that do not match the search string?

Options:

A.

‘None’ : ‘block’

B.

‘Visible : ’hidden’

C.

‘Hidden, visible

D.

‘Block’ : ‘none’

Question 12

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

Choose 2 answers

Options:

A.

Let countingDown = function(startNumber) {

If ( startNumber >0) {

console.log(startNumber) ;

return countingDown(startNUmber);

} else {

return startNumber;

}};

B.

Function factorial ( numVar ) {

If (numVar < 0) return;

If ( numVar === 0 ) return 1;

return numVar -1;

C.

Const sumToTen = numVar => {

If (numVar < 0)

Return;

return sumToTen(numVar + 1)};

D.

Const factorial =numVar => {

If (numVar < 0) return;

If ( numVar === 0 ) return 1;

return numVar * factorial ( numVar - 1 );

};

Question 13

Refer to the code below:

Question # 13

What is the value of result after line 10 executes?

Options:

A.

Error: myFather.job is not a function

B.

John Developer

C.

undefined Developer

D.

John undefined

Question 14

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

True + ‘13’ + NaN

Options:

A.

‘ 113Nan ’

B.

14

C.

‘ true13 ’

D.

‘ true13NaN ’

Question 15

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

Options:

A.

The associated class contains some asynchronous functions.

B.

The associated function will always return a promise

C.

The associated function can only be called via asynchronous methods

D.

The associated sometimes returns a promise.

Question 16

Which option is a core Node,js module?

Options:

A.

Path

B.

Ios

C.

Memory

D.

locate

Question 17

Refer to the code below:

const event = new CustomEvent(

//Missing Code

);

obj.dispatchEvent(event);

A developer needs to dispatch a custom event called update to send information about

recordId.

Which two options could a developer insert at the placeholder in line 02 to achieve this?

Choose 2 answers

Options:

A.

‘Update’ , (

recordId : ‘123abc’

(

B.

‘Update’ , ‘123abc’

C.

{ type : ‘update’, recordId : ‘123abc’ }

D.

‘Update’ , {

Details : {

recordId : ‘123abc’

}

}

Question 18

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 19

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

Question 20

A developer is leading the creation of a new web server for their team that will fulfill API requests from an existing client.

The team wants a web server that runs on Node.Js, and they want to use the new web framework Minimalist.Js. The lead developer wants to advocate for a more seasoned back-end framework that already has a community around it.

Which two frameworks could the lead developer advocate for?

Choose 2 answers

Options:

A.

Gatsby

B.

Angular

C.

Express

D.

Koa

Question 21

Refer to the code below:

Const pi = 3.1415326,

What is the data type of pi?

Options:

A.

Double

B.

Number

C.

Decimal

D.

Float

Question 22

myArraym can have one level, two levels, or more levels.

Which statement flattens myArray when it can be arbitrarily nested?

Options:

A.

myArray. reduce ((prev, curr) => prev.concat(curr) [ ]);

B.

myArray. join (","). split (",");

C.

[ ] .concat {. . .myArray) ;

D.

myArray.flat(Infinity);

Question 23

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

Question 24

developer is trying to convince management that their team will benefit from using

Node.js for a backend server that they are going to create. The server will be a web server that

handles API requests from a website that the team has already built using HTML, CSS, and

JavaScript.

Which three benefits of Node.js can the developer use to persuade their manager?

Choose 3 answers:

Options:

A.

Installs with its own package manager to install and manage third-party libraries.

B.

Ensures stability with one major release every few years.

C.

Performs a static analysis on code before execution to look for runtime errors.

D.

Executes server-side JavaScript code to avoid learning a new language.

E.

Uses non-blocking functionality for performant request handling .

Question 25

Refer to the following code:

Question # 25

What is the output of line 11?

Options:

A.

[1,2]

B.

["bar", "foo"]

C.

["foo:1", "bar:2"]

D.

["foo", "bar"]

Question 26

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

simply:

.

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?

Options:

A.

True positive

B.

True negative

C.

False positive

D.

False negative

Question 27

A developer has an is Dog function that takes one argument cat. They want to schedule the function to run every minute.

What is the correct syntax for scheduling this function?

Options:

A.

setInterval(isDog, 60000,'cat');

Question 28

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?

Options:

A.

The z variable is assigned the correct object.

B.

The z variable is assigned the correct object but this.name remains undefined.

C.

Window.name is assigned to ‘hello’ and the variable z remains undefined.

D.

Window.m is assigned the correct object.

Question 29

Refer to the string below:

const str = 'Salesforce';

Which two statements result in the word 'Sales'?

Choose 2 answers

Options:

A.

str.substr(1, 5);

B.

str.substr (0, 5);

C.

str.substring (1, 5);

D.

str.substring (0, 5);

Question 30

Refer to the following code:

<html lang=”en”>

<body>

<div onclick = “console.log(‘Outer message’) ;”>

<button id =”myButton”>CLick me<button>

<script>

function displayMessage(ev) {

ev.stopPropagation();

console.log(‘Inner message.’);

}

const elem = document.getElementById(‘myButton’);

elem.addEventListener(‘click’ , displayMessage);

</script>

What will the console show when the button is clicked?

Options:

A.

Outer message

B.

Outer message

Inner message

C.

Inner message

Outer message

D.

Inner message

Question 31

Given the following code:

Question # 31

is the output of line 02?

Options:

A.

''x''

B.

''null'''

C.

''object''

D.

''undefined''

Question 32

Refer to the following code block:

class Animal{

constructor(name){

this.name = name;

}

makeSound(){

console.log(`${this.name} is making a sound.`)

}

}

class Dog extends Animal{

constructor(name){

super(name)

this.name = name;

}

makeSound(){

console.log(`${this.name} is barking.`)

}

}

let myDog = new Dog('Puppy');

myDog.makeSound();

What is the console output?

Options:

A.

Puppy is barking

Question 33

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

Load More JavaScript-Developer-I Questions 
Page: 1 / 22
Total 215 questions