Exam JavaScript-Developer-I Topic 3 Question 117 Discussion

Actual exam question for Salesforce's JavaScript-Developer-I exam
Question #: 117
Topic #: 3
Refer to the code below:
01 function changeValue(param) {
02 param = 5;
03 }
04 let a = 10;
05 let b = a;
06
07 changeValue(b);
08 const result = a + ' - ' + b;
What is the value of result when the code executes?

Suggested Answer: D Vote an answer

We must understand pass-by-value for primitives in JavaScript.
* Initial values:
let a = 10;
let b = a; // b gets a copy of the value 10
So:
* a is 10
* b is 10 (independent copy)
* Function call:
changeValue(b);
Function definition:
function changeValue(param) {
param = 5;
}
* param receives the value of b, which is 10.
* Inside the function, param is a local variable .
* param = 5; changes only this local copy.
* It does not affect b outside the function.
After the function call:
* a is still 10.
* b is still 10.
* Result:
const result = a + ' - ' + b;
* a is 10.
* b is 10.
* String concatenation: ' 10 - 10 ' .
So result is:
" 10 - 10 "
Therefore, the correct option is:
The answer: D
Study Guide Concepts:
* Primitive values (numbers, strings, booleans) are passed by value
* Function parameters as local variables
* String concatenation with +
* Difference between mutating references vs primitives

by Larry at Jun 09, 2026, 08:46 PM

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
Nick name: Submit Cancel
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

0
0
0
10