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 trialLowell Wetzel
2,739 PointsThe quiz asks for a conditional statement. What is a conditional statement if not an "IF" statement?
I put in an "IF" statement and get an error that the "first part of the question is now wrong". The problem is I don't understand what the test expects me to do next. I can put in a thousand different solutions.
var answer = prompt("What is the best programming language?");
if (answer.toUpperCase() === 'JAVASCRIPT') {
alert('You are correct');}
else {
alert('Not correct');
}
<!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>
john larson
16,594 PointsLowell, what I do whenever possible is copy and paste the string parts of challenges from the question into the answer. That way when I get it wrong it's probably my logic and not a typo. As far as the "task one is no longer passing"... That is misleading. It usually just mean you got something wrong on the current task. (unless you deleted the first task)
3 Answers
john larson
16,594 Pointsvar answer = prompt("What is the best programming language?")
if (answer === "JavaScript") {
alert("You are correct");
} else {
alert("JavaScript is the best language!")
}
Josh Salyer
7,265 PointsWell the question asks you to specifically create a conditional statement that checks if the text entered in the prompt is equal to "JavaScript". If it is then alert the user with the message "You are correct". If it isn't "JavaScript", then alert the user with the message "JavaScript is the best language!". So your answer might be something like:
var answer = prompt("What is the best programming language?");
if (answer === "JavaScript") {
alert("You are correct");
} else {
alert("JavaScript is the best language!");
}
Sometimes with these challenges, you just need to phrase things exactly as they ask. Hope that helps!
Sakis Stefanopoulos
1,073 Pointsvar answer = prompt('What is the best programming language?'); if ( answer === 'JavaScript' ); { alert("You are correct"); } else { alert("JavaScript is the best language!"); } I can't procced. It says that i have a syntax error but i can't find it
john larson
16,594 Pointsjohn larson
16,594 PointsHi, it looks like your else clause is not printing what they asked for. These challenges can be picky about that kind of stuff. Also your code looks like it would work in real life. But also they were looking for answer === "JavaScript" not javascript converted to upper case... Like I said what you did makes perfect sense. It's just not what they were looking for