Practice Free Salesforce Certified JavaScript Developer Exam Online Questions
Refer to the following code:

What is the output of line 11?
- A . [1,2]
- B . ["bar", "foo"]
- C . ["foo:1", "bar:2"]
- D . ["foo", "bar"]
Refer to following code block:
Let array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,]; Let output =0;
For (let num of array){
if (output >0){
Break;
}
if(num % 2 == 0){
Continue;
}
Output +=num;
What is the value of output after the code executes?
- A . 16
- B . 36
- C . 11
- D . 25
A developer needs to test this function:
01const sum3 = (arr) => (
02if (!arr.length) return 0,
03if (arr.length === 1) return arr[0],
04if (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
- 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);
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)

- A . Option A
- B . Option B
- C . Option C
- D . Option D
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?
- A . setInterval(isDog, 60000,’cat’);
Refer to the code below:
Const searchTest = ‘Yay! Salesforce is amazing!” ;
Let result1 = searchText.search(/sales/i);
Let result 21 = searchText.search(/sales/i);
console.log(result1);
console.log(result2);
After running this code, which result is displayed on the console?
- A . > true > false
- B . > 5 >undefined
- C . >5>-1
- D . >5>0
A developer has the function, shown below, that is called when a page loads.
function onload() {
console.log(“Page has loaded!”);
}
Where can the developer see the log statement after loading the page in the browser?
- A . Terminal running the web server.
- B . Browser performance toots
- C . Browser javaScript console
- D . On the webpage.
Refer to the code below:

Line 05 causes an error.
What are the values of greeting and salutation once code completes?
- 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.
Given the code below:
const delay = sync delay => {
Return new Promise ((resolve, reject) => {
setTimeout (resolve,delay);});};
const callDelay =async () => {
const yup =await delay (1000);
console.log (1);
What is logged to the console?
- A . 123
- B . 132
- C . 213
- D . 231
Refer to the code below:

What is the result when the Promise in the execute function is rejected?
- A . Resolved1 Resolved2 Resolved3Resolved4
- B . Rejected
- C . Rejected Resolved
- D . Rejected1 Rejected2 Rejected3 Rejected Rejected Rejected4
