Exam JavaScript-Developer-I Topic 1 Question 69 Discussion
Actual exam question for Salesforce's JavaScript-Developer-I exam
Question #: 69
Topic #: 1
Question #: 69
Topic #: 1
Refer to the code below:
let strNumber = ' 12345 ' ;
Which code snippet shows a correct way to convert this string to an integer?
let strNumber = ' 12345 ' ;
Which code snippet shows a correct way to convert this string to an integer?
Suggested Answer: C Vote an answer
The correct answer is C .
The original option contains a typing error. It should use the existing variable name:
let numberValue = Number(strNumber);
The value of strNumber is a string:
' 12345 '
Using Number() converts the numeric string into a JavaScript number:
12345
So after execution:
typeof numberValue;
returns:
" number "
Professional review of each option:
Option
Result
Explanation:
A
Incorrect
JavaScript does not have a standard global Integer() conversion function.
B
Incorrect
Strings do not have a standard .toInteger() method.
C
Correct
Number(strNumber) correctly converts ' 12345 ' into 12345.
D
Incorrect
This is not valid JavaScript casting syntax.
A commonly used alternative would also be:
let numberValue = parseInt(strNumber, 10);
But from the provided answer choices, the verified answer is C .
The original option contains a typing error. It should use the existing variable name:
let numberValue = Number(strNumber);
The value of strNumber is a string:
' 12345 '
Using Number() converts the numeric string into a JavaScript number:
12345
So after execution:
typeof numberValue;
returns:
" number "
Professional review of each option:
Option
Result
Explanation:
A
Incorrect
JavaScript does not have a standard global Integer() conversion function.
B
Incorrect
Strings do not have a standard .toInteger() method.
C
Correct
Number(strNumber) correctly converts ' 12345 ' into 12345.
D
Incorrect
This is not valid JavaScript casting syntax.
A commonly used alternative would also be:
let numberValue = parseInt(strNumber, 10);
But from the provided answer choices, the verified answer is C .
by Riva at Jun 15, 2026, 11:29 AM
0
0
0
10
Comments
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.
Report Comment
Commenting
You can sign-up / login (it's free).