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 Basics (Retired) Making Decisions with Conditional Statements Introducing Conditional Statements

sean farrelly
sean farrelly
1,614 Points

add 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 !" .

app.js

index.html
<!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>
sean farrelly
sean farrelly
1,614 Points

the 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!");}

3 Answers

Sean M
Sean M
7,344 Points

For 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
Mike Bozee
39,385 Points

Here, 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
sean farrelly
1,614 Points

no 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
Mike Bozee
39,385 Points

Notice 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
sean farrelly
1,614 Points

yeah i passed the task

Thanks for the help .

If 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
sean farrelly
1,614 Points

its 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
sean farrelly
1,614 Points

i passed the task thanks for the help .