Text to Number
EasyAcc. 97.2%
+15 XP 5
Filtering Text
When users type data like weight into a form, they might write "150kg". To do math safely, we need to extract only the numeric part. parseInt() is highly useful to grab a leading whole number from a string.
The Assignment
Your function receives a raw text input named data.
- Use
parseInt()to convert thedatastring into a clear integer. - Add a bonus weight of 10 to it.
- Return the final numeric value.
01EXAMPLE 1
Input
data = "150kg"Output
160Explanation: parseInt("150kg") is 150, plus 10 is 160.
Constraints
- Use parseInt().
- Return the result as a number.
FundamentalsTypesMath
JavaScriptSystem handles I/O — write your function only
Loading...
5 Hidden
Input Arguments
data"150kg"
Expected Output
160
Click RUN to test your solution