Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript Loops, Arrays and Objects Tracking Multiple Items with Arrays Build a Quiz Challenge, Part 1 Solution

parseInt and toUpperCase together?

Hey guys. I was just wondering if I want numbers and strings as answers, how should I do it? It's seems like parseInt and toUpperCase are "kicking" each other out. I've tried a several ways, but none seems to work.

Do you mean that some answers will be numbers and other answers will be strings?

1 Answer

Hi, you can only use parseInt on a string that contains only numbers because you are saying to convert this string to an integer. It will not work on a string of something like "abc123". You would need to have a separate variable for your string of numbers if you want to convert it to an integer. From there you could concatenate your variable of uppercased letter string to your variable of integers. Hopefully that helps to point you in the right direction.

Hey! Thanks for your answer! The problem I had fixed itself somehow. I had 3 questions. 2 with string answers, 1 with a number. I was just wondering if parseInt(response.toUpperCase()) can be a thing or not. You know, just to make sure we accept numbers and lowercase, uppercase versions too!