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
Unsubscribed User
17,284 PointsNeed Help Please
Add an else clause to complete the conditional statement. Inside the else clause add another alert that says "JavaScript is the best language!"
My code...
var answer = prompt('What is the best programming language?');
if (answer === 'JavaScript') {
alert = ("<p>You are correct</p>");
} else {
alert = ("<p>JavaScript is the best language!</p>");
}
What am I doing wrong here? Thanks
4 Answers
paul white
13,958 PointsJust remove the "=" from the Alerts:
var answer = prompt('What is the best programming language?');
if (answer === 'JavaScript') {
alert("<p>You are correct</p>");
} else {
alert("<p>JavaScript is the best language!</p>");
}
But also within the alert function the html p tags may not be necessary
Sobin Sebastian
5,348 Pointsthe correct answer is: var answer = prompt("What is the best programming language?"); if ( answer === "JavaScript" ) { alert("You are correct"); }else{ alert("JavaScript is the best language!"); }
Tommy Gebru
30,164 PointsHey Dana
try removing the paragraph tags and tell me if that works
Unsubscribed User
17,284 PointsIt passed with the paragraph tags, I just needed to remove the "=". I used the paragraph tags because that's the way the video tut was showing it. Thanks guys.
Umar A
4,041 PointsUmar A
4,041 PointsI was gonna say the same thing. Good job