Exam JS-Dev-101 Topic 1 Question 91 Discussion
Actual exam question for Salesforce's JS-Dev-101 exam
Question #: 91
Topic #: 1
Question #: 91
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 Werner at Sep 05, 2026, 09:02 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).