## Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

### Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

# Why does it show alert box 2 times?

Here is my code.

```function quiz() {
a = parseInt(prompt("Type the lowest possible value"));
b = parseInt(prompt("Type the highest possible value"));
result = Math.floor(Math.random() * (b - a + 1)) + a;
return result;

}
quiz();

document.write("Your number is " + quiz());
```

edited code for formatting.

AH yeah I see what you are saying.

Your are calling the function quiz() twice

```function quiz() {
a = parseInt(prompt("Type the lowest possible value"));
b = parseInt(prompt("Type the highest possible value"));
result = Math.floor(Math.random() * (b - a + 1)) + a;
return result;

}
quiz();  //you don't need to call quiz() here...you are just calling it and not doing anything with it

document.write("Your number is " + quiz()); //since you are calling quiz() here for use in your document.write statement
```

thank u)

you're welcome :)

You have 2 prompt statements.

```a = parseInt(prompt("Type the lowest possible value"));
b = parseInt(prompt("Type the highest possible value"));
```

no, after these 2 times, it asks 2 times again. just try it and you will see