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 Simplify Repetitive Tasks with Loops `do ... while` Loops

Jerry Schrader
Jerry Schrader
4,396 Points

code not working

Workspace gives a blank page, and JSBin throws error. here is my code:

var randomNumber = getRandomNumber(10); var guess; var guessCount = 0; var correctGuess = false;

function getRandomNumber( upper ) { var num = Math.floor(Math.random() * upper) + 1; return num; }

do { guess = prompt('What is my number under 10'); guessCount += 1; if(parseInt(guess) === randomNumber) { correctGuess = true; } } while ( ! correctGuess );

document.write("You got it");

can you format your code inside your questions so we can take a look at your problem better.

if you don't know how please see the Markdown Cheatsheet just above the post comment button.

1 Answer

Jake Lundberg
Jake Lundberg
13,965 Points

I copy and pasted the code you listed, and it seems to work fine on my end. Do you have additional code that may be interfering?

Jerry Schrader
Jerry Schrader
4,396 Points

no, that's it. I tried it in jsbin, and no good, just got an error (on top of the document.write can be a form of eval. error), and in workspaces, I get an empty page. I guess as long as it's right, I'll move on. Thanks!