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 trialMari Selvan
2,438 Pointswhy we should not use the variable "randomnumber" instead of getRandomNumber(upper); in place of guess=______?
because both are same....
3 Answers
Serkan Simsir
Courses Plus Student 7,354 PointsBecause if you replace getRandomNumber(upper) for randomNumber you don't actually generate a random guess, you tell your guess already what the number is, which results in your loop will run just once while it's empty, you'll always get computer needed 1 attempt to get it right! Hope I'm not mistaking.......
Elena Paraschiv
9,938 PointsThat makes sense. Thanks. Was just about to ask the same question.
Mari Selvan
2,438 Pointsexactly... Mishkin
Jacob Mishkin
23,118 PointsIts mostly used for style and debugging purposes more so than anything else. and it looks cleaner I personally think.
here is a great article on named function expressions.
Jacob Mishkin
23,118 PointsJacob Mishkin
23,118 Pointscan you post some code as to make it easier for us to see visually what your questions is. Are you saying that the variable "randomNumber" is the same as the function getRandomNumber, and why use the variable in the condition statement in the video, rather than the function?