On line 1, create a variable myColor and give it a string value. On line 2, print the length of myColor to the console. var "myColor"= "red" console.log("DD".length); It's saying "Oops, try again. There was a problem with your syntax." Please Help!
So "myColor" would need to become just myColor.
There's one more thing.
In the console.log() parentheses you'll want to use the variable name like before and then .length. Not "DD" as that is not valid in this context.
Sorry but I am still stuck
i tried taking the quotes off but it said thisOops, try again. It looks like 'myColor' on line 2 was not defined before it was used. This means either you need to define it, 'myColor' is spelled incorrectly or you need quotes around 'myColor'.
Okay lets try it this way then..
var "myColor"= "red"
What you should have instead is:
var myColor = "red";
For your last line you wrote:
It should be showing as:
Why? Because the exercise wants us to learn how to use our variables and their values. By putting .length after the variable name we're going to get the length of the string we are testing. Console.log() will print that and show us how many characters are present in the myColor variable. It should be 3 in this case because red contains 3 characters.
I hope that's more understandable now.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.