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 trialsean farrelly
1,614 Pointsadd an else clause to complete the conditional statement. inside the else clause add another alert that says javascript
add an else clause to complete the conditional statement. inside the else clause add another alert that says "javascript is the best language !" .
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JavaScript Basics</title>
</head>
<body>
<script src="app.js"></script>
</body>
</html>
3 Answers
Sean M
7,344 PointsFor future reference, the questions asks to use windows.alert()
Here's what I got:
var answer = prompt("What is the best programing language?");
if (answer === "JavaScript") {
window.alert("You are correct!");
} else {
window.alert("JavaScript is the best language!");
Mike Bozee
39,385 PointsHere, try this:
var answer = prompt('What is the best programming language?');
if (answer === 'JavaScript') {
alert('You are correct');
} else {
alert('JavaScript is the best language!');
}
sean farrelly
1,614 Pointsno it didn't pass here is the code i have typed so far var answer = prompt ("what is the best programming language?"); if (answer === "JavaScript") { alert ("You are correct";)} else { alert (" JavaScript is the best language!");
Mike Bozee
39,385 PointsNotice difference between my code and your code here. Specifically, your alert ("You are correct";) and else { alert (" JavaScript is the best language!");
My code above does indeed pass. Also, see 'Markdown Cheatsheet' when posting for tips on embedding code.
sean farrelly
1,614 Pointsyeah i passed the task
Thanks for the help .
Bruno Areias
5,181 PointsIf you reached that section of the code you should have this already on your app.js file
var answer;
answer = promt();
if(answer === "JavaScript"){
alert("some string here i don't remember exactly");
}
All you have to do is to after all that code is
else{
alert("javascript is the best language !");
}
sean farrelly
1,614 Pointsits not passing here is the code i have typed so far var answer = prompt ("what is the best programming language?"); if (answer === "JavaScript") { alert ("You are correct";)} else { alert (" JavaScript is the best language!");
sean farrelly
1,614 Pointsi passed the task thanks for the help .
sean farrelly
1,614 Pointssean farrelly
1,614 Pointsthe help button is frozen when i get to task three so this is why i asked the question on task one for task three .the code i was trying is as follows var answer= prompt ("what is best programming language?"); if (answer == "javaScript") { alert ("You are correct "); else { alert ("JavaScript is the best language!");}