Reputation: 89
The code shown below works and it returns true. But I'm being told that there is another problem which I'm not catching. Perhaps a fresh pair of eyes will see what I don't. The error says:
Oops, try again. Make sure your if/else statement evaluates to true!
Code:
Here is the starting code they provided:
("Jon".length * 2 / (2+1) === )
{
console.log("The answer makes sense!");
}
else
Here is my answer with some things filled in:
if ("Jon".length * 2 / (2+1) === 2) {
console.log("True");
} else {
console.log("Error Error Error");
}
Assignment:
Math
We saw basic math before. The basic math symbols we learned in school work here. Even the order in which the computer understands the math is the same as in school!
Code:
- ( ): control order of operations
- * and /: multiplication and division
- - and +: subtraction and addition
Examples:
- 100/10 evaluates to 10
- "Jane".length + 5 evaluates to 9
- 5*(3+1) evaluates to 20
Instructions
Complete the missing bits of code to construct the if / else statement. Make the condition evaluate to true.
Finish the else statement by printing out the string "Error Error Error" to the console.
Upvotes: 0
Views: 150
Reputation: 89
Codecademy is very strict in uses of there lessons. The functionality of the problem above was correct, however the site doesn't like it when you customize there code like I did. When modified the text in the console.log statement, it prevented from moving forward with the lesson.
// Their version
console.log("The answer makes sense!");
// Your version
console.log("True");
I learned that often on Codecademy, you have to do exactly what the instructions say, or even more, than writing code that works.
Upvotes: 1
Reputation: 56488
Codecademy uses a number of methods to determine whether or not you have passed the lesson. They seem to check the ending value of various objects in the code (the value of variables, return value of functions...), but they also parse the code you submitted using regular expressions or similar, looking for certain things. Unfortunately, determining what those things might be is sometimes more of a puzzle than the code they wanted you to write in the first place.
Now that you have updated your question with the assignment text and the starting code you were given, as well as your submitted code, the most likely issue would seem to be that you modified the text in the true-case console.log
statement.
// Their version
console.log("The answer makes sense!");
// Your version
console.log("True");
They are probably checking that the expected string was logged to the console. Since you changed what was logged, this test would be failing.
Often on Codecademy, "do exactly what the instructions say" counts as much, or even more, than writing code that works.
Upvotes: 0