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 trial

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!