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

List of questions
Question 121

A developer is setting up a new Node.js server with a client library that is built using events and callbacks.
The library:
• Will establish a web socket connection and handle receipt of messages to the server ?
• Will be imported with require, and made available with a variable called we.
The developer also wants to add error logging if a connection fails.
Given this info, which code segment shows the correct way to set up a client with two events that listen at execution time?
Question 122

Refer to the code snippet below:
Let array = [1, 2, 3, 4, 4, 5, 4, 4];
For (let i =0; i < array.length; i++)
if (array[i] === 4) {
array.splice(i, 1);
}
}
What is the value of array after the code executes?
Question 123

Refer to HTML below:
<p> The current status of an Order: <span id ="status"> In Progress </span> </p>.
Which JavaScript statement changes the text 'In Progress' to 'Completed' ?
Question 124

A developer wants to leverage a module to print a price in pretty format, and has imported a method as shown below:
Import printPrice from '/path/PricePrettyPrint.js';
Based on the code, what must be true about the printPrice function of the PricePrettyPrint module for this import to work ?
Question 125

What are two unique features of functions defined with a fat arrow as compared to normal function definition?
Choose 2 answers
Question 126

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 to make this code work as expected?
Question 127

The developer wants to test this code:
Const toNumber =(strOrNum) => strOrNum;
Which two tests are most accurate for this code?
Choose 2 answers
Question 128

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
Question 129

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?
Question 130

Refer to the following code that performs a basic mathematical operation on a provided input:
function calculate(num) {
Return (num +10) / 3;
}
How should line 02 be written to ensure that x evaluates to 6 in the line below?
Let x = calculate (8);
Question