Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialcyber voyager
8,859 PointsCan't understand the parseInt explanation on MDN.
I learned how to use the parseInt() function on the lessons that I did here on treehouse but as I was going through a challenge I stumbled onto this code which I had a hard time to understand, parseInt(theNumber, 10); What does 10 mean? I checked the MDN but I couldn't understand what it meant, anyways I am sure that this is not very important but I would like to know what is it? Why the teachers didn't talk about this. Thank you very much for your reply whoever you are :) Something else! I want to know how to insert emotes on treehouse :P
2 Answers
Evgeniia Mas
4,452 PointsHello, Stavros! Let me try to make it a little bit more clear for you. Imagine you have a piece of bread and want to make a sandwich. You have three different kinds of cheese: Edem, Camembert and Mozzarella. All these can give you a sandwich with cheese, but at the moment you want to get a sandwich with Mozzarella, it's your goal. So you will take Mozzarella and put it on a piece of bread. If we imagine that sandwich must me prepared by computer, you have to give it absolutely clear instructions that it must take a particular kind of cheese to get the result you expect. Similarly, there are several numeral systems (as we suggest here kinds of cheese))). So, for example, number twelve in decimal (10) looks like 12, but in binary system (2) it will look like 1100. That is not what you expect to see executing your function if your goal to see twelve as 12 (like a sandwich with mozarella). Pointing in function 10 you make your instruction exact! Like Mozarella, not Edem!!!! That's why in your example you take a function parseInt and say to it: take "theNumber" and convert it in decimal (10) format . After running you get the result you wish.
hamdi ismail
Courses Plus Student 8,927 Pointsok that line of code make a coversation for theNumber to the base 10 (decimal base) and there is ton of conversations between bases 10 to 16, 2 to 8 ect.. and they didn"t explaint because you don't need it in your future and a little information decimal is the numbers we use now '0 to 9' and binary '2' which computers use 0 and 1
cyber voyager
8,859 PointsThank you for your reply mate, I didn't understand it but since it's not important it's ok
cyber voyager
8,859 Pointscyber voyager
8,859 PointsHello, Evgeniia Mas first I just feel like hugging you for your well-explained fun to read answer. I just had an aww moment here so what you are explaining me here is that there are two types of "cheese" mozzarella which is in decimal (10) which represents converts a 12 into 12 and then we got another cheese which is in binary system (2) so we are talking about 0s and 1s so our 12 would be 1100. Thank you very very much for the time that you put into your answer it is very much appreciated!