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 trialamyzhang3
914 PointsWhen a browser runs the code listed below, what will the user see?
please var spaceship =0; if (spaceShip===0) { alert("You are correct") } else {alert("you are wrong")}
please let me know the answer thanks!
2 Answers
Umesh Ravji
42,386 PointsHi Amy, you got this. See code with comments below :)
// Declare a variable named spaceShips and set its value to be 0
var spaceShips = 0;
// Conditional check to see if the spaceShips variable has its value set to 0
if (spaceShips === 0 ) {
// If spaceShips is 0, this code branch will be executed *hint*
alert('You lose!');
} else {
// If spaceShips is not 0, this code branch will be executed
alert('You are still alive!');
}
Steve Warburton
4,156 PointsThe answer is 'You Lose'...