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 trialGrzegorz Sypek
9,311 PointsWhy my code doesn't work in console.log but in window.alert work fine?
function getRandomNumber( lower, upper) {
return Math.floor(Math.random() * (upper - lower + 1)) + lower; }
alert( getRandomNumber(1, 6) ); alert( getRandomNumber(1000, 10006) ); console.log( getRandomNumber(0.5, 0.9) ); console.log( getRandomNumber(3, 5) );
3 Answers
Adam Beer
11,314 PointsYour code is absolute correct. The first 2 alert prompt write on the window the 2 results. The second 2 console.log methods write the result in the console. Open the console with F12 if you use chrome or right click and select the investigation. You can use it Ctrl+Shift+I.
Grzegorz Sypek
9,311 PointsMy problem was with the Chrome browser. The console function doesn't write me result because it was marked as " hidden" in some strange way. Now it works fine but it was good to get an answer from you. Thanks Adam.
Ed Bundy
5,408 Pointsconsole.log() doesn't work for me in either Safari or Chrome. Not sure what you mean about "hidden"..
Adam Beer
11,314 PointsPlease show we your whole code.
Ed Bundy
5,408 PointsI'm not sure what the problem was. I moved on with the other work on the track and today saw you reply. Went back and ran the code and now it is working in both. I'm not sure what the problem was. Maybe I wasn't using the console right at the time.
Adam Beer
11,314 PointsAdam Beer
11,314 PointsCode
Wrap your code with 3 backticks (```) on the line before and after. If you specify the language after the first set of backticks, that'll help us with syntax highlighting.