+ 1

Hi im new learner and i noticed in Javascript for the tests there's always input given but why is it always "10"?

parseInt(readLine(), 10); What is the 10 meaning?

12th Nov 2022, 3:27 PM
Pravesh Maharaj
Pravesh Maharaj - avatar
3 ответов
+ 4
it's base of number system to be converted from input of string type. Base 10 : decimal numbers Base 2 : binary Base 8 : octal, etc..
12th Nov 2022, 4:09 PM
Jayakrishna 🇮🇳
+ 4
Pravesh Maharaj the second parameter, radix, tells parseInt() what number base to use for interpreting the value. Most of the time you expect input in base 10 (decimal) so 10 is the radix. Radix 10 means there are 10 possible digits, 0 - 9. If the input number should be in binary, then radix is 2 because there are two possible digits, 0 - 1. For octal the radix is 8 (0 - 7), and for hexadecimal, radix is 16 (0 - F).
12th Nov 2022, 4:19 PM
Brian
Brian - avatar
+ 1
Thank you both!
13th Nov 2022, 8:06 AM
Pravesh Maharaj
Pravesh Maharaj - avatar