27.conclusion javascript


#1

in this task that i have it keeps saying my syntax is messed up or something.Does anyone know whats wrong with this

var mycolor("red".length);
console.log("red".length);


#2

Are you sure you are supposed to write red as a string?


#3

yes thats the color that i chose because its say my color. right?


#4

Try taking out the quotation marks.


#5

that didnt work it says on line one that red is not defined


#6

Wait lemme see what the level is about...


#7

ok thanks its like a review type thing


#8

Ah, gotcha. Okay, what you are supposed to do is to first define myColor (note the capitalization):

var myColor = "Red" //in your case

Now, there is no length of red. So, instead of "red", you have to put:

console.log(myColor.length);

Hope it helped! :smiley:


#9

ohhhhhh ok thank you are the best


#10

The first line is where the issues arise:

var myColor = "red";

This statement declares a variable, myColor and defines it with a string primitive assignment operation.

= is the assignment operator by which we set the values referenced by their variable.

We can log the properties of the referenced object, in this case a 'string' type object, "red"...

console.log(myColor.length);

It is worth noting that once we declare a variable, we can assign values or objects to that variable as the program requires with never declaring it again, just re-defining it...

myColor = "blue";
console.log(myColor.length); // 4
myColor = "purple";
console.log(myColor.length); // 6

#11

Hi Friends
I don´t know what am i doing wrong, but still not ok for the system

var myColor= "red";
console.log=(myColor.length);

The message that system gives me is : Oops, try again. It looks like you didn't print the length myColor to the console!


#12

log(( is a function, so call it like a function with your output as the argument...

console.log(myColor.length);

#13

Thanks Mtf.
What stupid i was to write down = !! :smile: didn´t realize!!
Thanks a lot!


#14

I've never met a stupid programmer, but I have met many who are occasionally blind to the obvious. That's human. Be easy on yourself. :smile:


#15

Thanks for your understanding mtf (sometimes, when you realize your mistake, you feel like a stupid. It was just my first reaction facing my mistake. That´s all :smile:
Best regards from Buenos Aires, Argentina. I´ll continue with the course. Thanks!


#16

i need help on the conclusion part 1
i put: var myColor = "turquoise";
console.log("myColor".length);
but it says Oops, try again. It looks like you didn't print the length myColor to the console!

i dont understand
please and thank you


#17

nvm i figured it out
it was the quotes


#18

Remove the quotes around `"myColor",

myColor.length

We never write variables in quotes. Quotes are for string primitives, only.


#20

A post was split to a new topic: Your code doesn't look quite right


#21

Yes because if you don't input red as a string then what happens is the computer won't run the code.