What's wrong with my Comparison code?


#1

Please check my code at ,
https://www.codecademy.com/courses/getting-started-v2/1/6?curriculum_id=506324b3a7dffd00020bf661#

and let me know what mistake I've made.

https://www.codecademy.com/courses/getting-started-v2/1/6?curriculum_id=506324b3a7dffd00020bf661#


Error Message

!**
Oops, try again. Make sure you typed in the string exactly, used .length, and used the right comparator.
**!


My code,
--------------------
var len = "I'm coding like a champ ".length;
console.log('Sentence Length is = ' + len);
if(len > 10){
    console.log('String Length Greater than 10');
}

----------------------


#2

Hey @rcrteam :slight_smile:
Your source code is definitely correct, I suggest you try running that JavaScript file on a website with a built-in compiler called Programmr to test that it's not just the website.
But it's not working simply because you used variables and conditions and those haven't been introduced to you yet.
To fix this error, just remove the variable and have that string with the function .length > 10

Hope this helps!!!


#3

It is a bit confusing....
but the only thing you should be using....
"I am coding as a champ".length > 10
throw out all the other code.....


#4

Thanks a lot for the explanation. It really Helped.


#5

Thanks for the help. I guess, I've used codes that was not expected to be used at the beginning level . I'll correct it, thanks.


#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.