Docsity

Salesforce Certified JavaScript Developer Study Guide, Exams of Advanced Education

Toggle sidebar
bg1
Salesforce Certified JavaScript Developer
(SP22) questions and answers
Refer to the code below:
Let foodMenu1 = ['pizza', 'burger', 'French fries'];Let finalMenu = foodMenu1; finalMenu.push('Garlic
bread');
What is the value of foodMenu1 after the code executes?
A [ 'pizza','Burger', 'French fires', 'Garlic bread']
B [ 'pizza','Burger', 'French fires']
C [ 'Garlic bread' , 'pizza','Burger', 'French fires' ]
D [ 'Garlic bread'] - CORRECT ANSWER B
Which statement accurately describes an aspect of promises?
A In a.then() function, returning results is not necessary since callbacks will catch the result of a
previous promise.
B .then() cannot be added after a catch.
C Arguments for the callback function passed to .then() are optional.
D .then() manipulates and returns the original promise. - CORRECT ANSWER C
A developer is wondering whether to use, Promise, then or Promise.catch, especially when promise
throws an error.
Which two promises are rejected?
pf3
pf4
pf5

Partial preview of the text

Download Salesforce Certified JavaScript Developer Study Guide and more Exams Advanced Education in PDF only on Docsity!

Salesforce Certified JavaScript Developer

(SP22) questions and answers

Refer to the code below: Let foodMenu1 = ['pizza', 'burger', 'French fries'];Let finalMenu = foodMenu1; finalMenu.push('Garlic bread'); What is the value of foodMenu1 after the code executes? A [ 'pizza','Burger', 'French fires', 'Garlic bread'] B [ 'pizza','Burger', 'French fires'] C [ 'Garlic bread' , 'pizza','Burger', 'French fires' ] D [ 'Garlic bread'] - CORRECT ANSWER B Which statement accurately describes an aspect of promises? A In a.then() function, returning results is not necessary since callbacks will catch the result of a previous promise. B .then() cannot be added after a catch. C Arguments for the callback function passed to .then() are optional. D .then() manipulates and returns the original promise. - CORRECT ANSWER C A developer is wondering whether to use, Promise, then or Promise.catch, especially when promise throws an error. Which two promises are rejected?

A. Promise.reject('cool error here').then(error => console.error(error)); B. New Promise(() => (throw 'cool error here'}).then(null, error => console.error(error))); C. New Promise((resolve, reject) => (throw 'cool error here'}).catch(error => console.error(error)); D. Promise.reject('cool error here').catch(error => console.error(error)); - CORRECT ANSWER CD 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? A window.addEventListener('load',personalizeWebsiteContext); B document.addEventListener(''onDOMContextLoaded', personalizeWebsiteContext); C window.addEventListener('onload', personalizeWebsiteContext); D Document.addEventListener('''DOMContextLoaded' , personalizeWebsiteContext - CORRECT ANSWER A Refer to the code below: Let textValue = '1984'; Which code assignment shows a correct way to convert this string to an integer? A Let numberValue = Integer(textValue); B Let numberValue = textValue.toInteger(); C Let numberValue = (Number)textValue; D Let numberValue = Number(textValue); - CORRECT ANSWER D

A TypeError: dan.name is not a function. B TypeError: Assignment to constant variable. C Hello John Doe D Hello Dan Doe - CORRECT ANSWER A 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? A ws.on ('connect', ( ) => { console.log('connected to client'); }}; ws.on('error', (error)=> { console.log('ERROR' , error); }}; - CORRECT ANSWER A 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? A. [1,2,3,4,5,4,4] B. [1,2,3,4,4,5,4] C. [1, 2, 3, 5] D. [1, 2, 3, 4, 5, 4] - CORRECT ANSWER D

A developer creates a class that represents a blog post based on the requirement that a Post should have a body author and view count. The Code shown Below: Class Post {// Insert code here This.body =body This.author =author; this.viewCount = viewCount; } } Which statement should be inserted in the placeholder on line 02 to allow for a variable to be set to a new instanceof a Post with the three attributes correctly populated? A. constructor (body, author, viewCount) { B super (body, author, viewCount) { C constructor() { D Function Post (body, author, viewCount) { - CORRECT ANSWER A Refer to HTML below:

The current status of an Order: In Progress

. Which JavaScript statement changes the text 'In Progress' to 'Completed'? A document.getElementById("status").Value = 'Completed' ; B document.getElementById("#status").innerHTML = 'Completed' ; C document.getElementById("status").innerHTML = 'Completed' ; D document.getElementById(".status").innerHTML = 'Completed' ; - CORRECT ANSWER C A developer wants to leverage a module to print a price in pretty format, and has imported a method as shown below:

B 0 1 2 2

C 0 1 1 2

D 0 0 1 2 - CORRECT ANSWER C