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
Hugo Elliott
11,174 PointsJavaScript Basic course - problem with one of the code challenges
Hi
I'm having a problem with one of the code challenges on the Javascript Basics course, specifically question 2 of this challenge Making Decisions with Conditional Statements
Task 1 asks
"Add a variable named answer and use the prompt() method to ask the question 'What is the best programming language?'"
I wrote the code
var answer = prompt("What is the best programming language?");
Which works and I get the normal "Well done you're doing great" message
Task 2 asks
"Add a conditional statement that opens an alert dialog box with the message "You are correct" when the answer is the string 'JavaScript'."
I wrote the code
var answer = prompt("What is the best programming language?"); if (answer.toUpperCase()==="JAVASCRIPT") { alert("You are correct"); }
I get the prompt which allows me to type "javascript", and an alert message saying "You are correct"
But I get an error message (and so can't progress to Task 3) saying
"Oops! It looks like Task 1 is no longer passing."
Which is kind of weird, because I haven't changed any of the code I wrote for Task 1.
I'm probably doing something wrong which is incredibly silly / basic, but any thoughts would be much appreciated.
thank you
3 Answers
Henrik Christensen
Python Web Development Techdegree Student 38,322 PointsIn the challenge you are not supposed to use .toUpperCase() because the challenge what the statement to be true when the answer is "JavaScript" and not "JAVASCRIPT" or "javascript".
I hope this helps you in any way :)
Hugo Elliott
11,174 PointsHi Henrik
Thank you, you're absolutely right.
Hugo
Clarke Criddell
5,946 Pointsvar answer = prompt('What is the best programing language?');