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 trialJonathan Weinstein
9,063 PointsCan anyone identify why the error message isn't showing up?
function getRandomNumber( lower, upper) {
if ( isNaN(lower) || isNaN(upper) ) {
throw new Error('You did not enter a numerical value');
}
return Math.floor(Math.random()*(upper - lower +1)) + lower;
}
console.log( getRandomNumber(3, adfg) );
1 Answer
Hugo Paz
15,622 PointsHi Jonathan,
The second argument you are passing to the function is interpreted as a variable. This is why you get an uncaught ReferenceError: adfg is not defined.
If pass it a string like this, your code will work:
console.log( getRandomNumber(3, 'adfg') );
Jonathan Weinstein
9,063 PointsJonathan Weinstein
9,063 PointsThanks, Hugo!