Labour Day Sale - Limited Time 60% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: 575363r9

Welcome To DumpsPedia

JavaScript-Developer-I Sample Questions Answers

Questions 4

The developer wants to test this code:

Const toNumber =(strOrNum) => strOrNum;

Which two tests are most accurate for this code?

Choose 2 answers

Options:

A.

console.assert(toNumber(‘2’) === 2);

B.

console.assert(Number.isNaN(toNumber()));

C.

console.assert(toNumber(‘-3’) < 0);

D.

console.assert(toNumber () === NaN);

Buy Now
Questions 5

A developer wants to use a try...catch statement to catch any error that countSheep () may throw and pass it to a handleError () function.

What is the correct implementation of the try...catch?

A)

B)

C)

D)

Options:

A.

Option

B.

Option

C.

Option

D.

Option

Buy Now
Questions 6

A developer wants to set up a secure web server with Node.js. The developer creates a

directory locally called app-server, and the first file is app-server/index.js

Without using any third-party libraries, what should the developer add to index.js to create the

secure web server?

Options:

A.

const https =require(‘https’);

B.

const server =require(‘secure-server’);

C.

const tls = require(‘tls’);

D.

const http =require(‘http’);

Buy Now
Questions 7

In which situation should a developer include a try .. catch block around their function call ?

Options:

A.

The function has an error that should not be silenced.

B.

The function results in an out of memory issue.

C.

The function might raise a runtime error that needs to be handled.

D.

The function contains scheduled code.

Buy Now
Questions 8

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 9

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.

Buy Now
Questions 10

A developer receives a comment from the Tech Lead that the code given below has

error:

const monthName = ‘July’;

const year = 2019;

if(year === 2019) {

monthName = ‘June’;

}

Which line edit should be made to make this code run?

Options:

A.

01 let monthName =’July’;

B.

02 let year =2019;

C.

02 const year = 2020;

D.

03 if (year == 2019) {

Buy Now
Questions 11

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 12

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

Buy Now
Questions 13

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.

Buy Now
Questions 14

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 ’

Buy Now
Questions 15

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

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

Options:

A.

window.name is assigned to 'hello' and the variable = remains undefined.

B.

window.m Is assigned the correct object.

C.

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

D.

The m variable is assigned the correct object.

Buy Now
Questions 16

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

Buy Now
Questions 17

Which javascript methods can be used to serialize an object into a string and deserialize

a JSON string into an object, respectively?

Options:

A.

JSON.stringify and JSON.parse

B.

JSON.serialize and JSON.deserialize

C.

JSON.encode and JSON.decode

D.

JSON.parse and JSON.deserialize

Buy Now
Questions 18

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

True + 3 + ‘100’ + null

Options:

A.

104

B.

4100

C.

‘3100null’

D.

‘4100null’

Buy Now
Questions 19

Refer to the code below:

Let textValue = ’1984’;

Which code assignment shows a correct way to convert this string to an integer?

Options:

A.

let numberValue = Number(textValue);

B.

Let numberValue = (Number)textValue;

C.

Let numberValue = textValue.toInteger();

D.

Let numberValue = Integer(textValue);

Buy Now
Questions 20

Given the following code:

Let x =(‘15’ + 10)*2;

What is the value of a?

Options:

A.

3020

B.

1520

C.

50

D.

35

Buy Now
Questions 21

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 22

Refer to the code below:

const addBy = ?

const addByEight =addBy(8);

const sum = addBYEight(50);

Which two functions can replace line 01 and return 58 to sum?

Choose 2 answers

Options:

A.

const addBy = function(num1){

return function(num2){

return num1 + num2;

}

B.

const addBy = function(num1){

return num1 + num2;

}

C.

const addBy = (num1) => num1 + num2 ;

D.

const addBY = (num1) => (num2) => num1 + num2;

Buy Now
Questions 23

Refer to the code below:

Line 05 causes an error.

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

Options:

A.

Greeting is Hello and salutation is Hello, Hello.

B.

Greeting is Goodbye and salutation is Hello, Hello.

C.

Greeting is Goodbye and salutation is I say Hello.

D.

Greeting is Hello and salutation is I say hello.

Buy Now
Questions 24

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

Buy Now
Questions 25

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:

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 to 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.addCallback(“click”, function() {

D.

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

Buy Now
Questions 26

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

Buy Now
Questions 27

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

Buy Now
Questions 28

Universal Container(UC) just launched a new landing page, but users complain that the

website is slow. A developer found some functions that cause this problem. To verify this, the

developer decides to do everything and log the time each of these three suspicious functions

consumes.

console.time(‘Performance’);

maybeAHeavyFunction();

thisCouldTakeTooLong();

orMaybeThisOne();

console.endTime(‘Performance’);

Which function can the developer use to obtain the time spent by every one of the three

functions?

Options:

A.

console.timeLog()

B.

console.getTime()

C.

console.trace()

D.

console.timeStamp()

Buy Now
Questions 29

Refer to the code below:

What is the result when the Promise in the execute function is rejected?

Options:

A.

Resolved1 Resolved2 Resolved3 Resolved4

B.

Rejected

C.

Rejected Resolved

D.

Rejected1 Rejected2 Rejected3 Rejected Rejected Rejected4

Buy Now
Questions 30

Refer the following code

what is the value of array after code executes?

Options:

Buy Now
Questions 31

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 32

A developer has an ErrorHandler module that contains multiple functions.

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

Options:

A.

Named

B.

All

C.

Multi

D.

Default

Buy Now
Questions 33

Refer to the code snippet:

Function getAvailabilityMessage(item) {

If (getAvailability(item)){

Var msg =”Username available”;

}

Return msg;

}

A developer writes this code to return a message to user attempting to register a new

username. If the username is available, variable.

What is the return value of msg hen getAvailabilityMessage (“newUserName” ) is

executed and getAvailability(“newUserName”) returns false?

Options:

A.

“Username available”

B.

“newUserName”

C.

“Msg is not defined”

D.

undefined

Buy Now
Exam Code: JavaScript-Developer-I
Exam Name: Salesforce Certified JavaScript Developer I (SP24)
Last Update: May 3, 2024
Questions: 219
$64  $159.99
$48  $119.99
$40  $99.99
buy now JavaScript-Developer-I