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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Tall Toad](https://secure.gravatar.com/avatar/3eab65d3d5efd718a7481dee73fbe70b?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Tall Toad
2,746 PointsWhy is console.log() not having an issue showing numbers without the parseInt?
// Collect input from a user
const choosenNumber = prompt("Whats your favourite number?");
// Convert the input to a number const favouriteNumber = (choosenNumber);// I know parseInt should be present before the (chosenNumber). But when I run this workspace on the browser, I'm not getting any errors or Nan.
// Use Math.random() and the user's number to generate a random number
const randomNumber = Math.floor( Math.random() * choosenNumber) + 1;
// Create a message displaying the random number
console.log(${randomNumber} is a number between 1 and ${favouriteNumber}.
);
1 Answer
![Steven Parker](https://uploads.teamtreehouse.com/production/profile-photos/969492/micro_tool_chess_set_2.jpg)
Steven Parker
230,688 PointsFor some operations, JavaScript can tell that a number is needed and it performs type coercion, which is essentially converting the string into a number for you automatically.
But you don't want to rely on this, since there will be other cases where it can't perform this for you. Here's an example where it won't work:
const choosenNumber = prompt("Whats your favourite number?");
const twice = choosenNumber + choosenNumber;
console.log(`${choosenNumber} added to itself is not ${twice}, is it?`);
Tall Toad
2,746 PointsTall Toad
2,746 PointsThanks for the reply Steven Parker, I'm new to coding. Some parts make sense some don't or eventually do. As a newbie, How does one evaluate if they are doing well or not?
Steven Parker
230,688 PointsSteven Parker
230,688 PointsIf you generally complete the quizzes and challenges with only occasionally needing to review a lesson, you're doing quite well indeed!