How do I print the length?


#1

Does anyone know how to do this
https://www.codecademy.com/courses/getting-started-v2/4/4?curriculum_id=506324b3a7dffd00020bf661
How do I print the length?


What is your name? Hi! Let's get to know each other. What is your name?
#2

Here with the instructions

  1. On line 1, create a variable myColor and give it a string value.

var myColor  = "Red"

2.On line 2, print the length of myColor to the console.

console.log(myColor.length )

#3

Thank you. I figured it out. I also do Khan Academy. Can you tell me how do this??


The JavaScript Moles in Holes Challenge


#4

Can you please help?


#5

Yeah create a drawMole function and call upon that function and line up the x and y coordinates with where the holes are.


#6

Hi sorry if I take too for respond you here what they aske you to

1 in the first step you just need to call the function drawMole, like that
In the bottom of the code

drawMole()

2 second step they aske you to put some argument inside the function drawMole. Put inside the function two name the first name molex and the second moleY.

3 they aske you to call the function drawMole().


#7

You aren't going to learn a darn thing if you simply ask others how to do everything. Always Google first, second and third before asking someone or posting on a forum. Best get in the habit early if you plan on sticking around. Although, that's not technically needed for what you asked considering there's a hint feature during exercises.


#8

I tried but my school blocks everything so Google isn't much help.


#10

For example, I'm stuck on this, and this is what I produced


#11

google was made by people, so people can be just as smart


#12

google isnt always the answer, maybe most of the time, but not always, since people made the internet and people are sometimes wrong, google must have some mistakes here and there, so it depends on the person your asking verses googling it.


#13

@boobear87
that's because pink is undefined. its nothing.

"pink" would make it a string of the word pink

"pink".length would mean its equal to 4.
(this statement is true) is also doing nothing either.
Don't forget about console.log.

After else you have to put a default value in. You can't compare anything any more, you would have to use else if again to check again. But you need an else statement to close it with it's default value, that will be used if the code doesn't fit any part of the if loop.

if("pink".length === 4){
console.log("This statement is true");
}else if ("pink".length === 3) {
console.log("This statement is false");
}else{
console.log("oops I broke somewhere");
}

Recap:

pink like that means nothing "pink" makes it a string "pink".length makes it the value of 4.

You need console.log to make things appear in the console. This is core to showing js in the console, and you should really know to use console.log by now.

else can't check anything only have a default value such as else { console.log("cake")

I suggest maybe re-going over some of the earlier lessons to get the core parts of javascript that you haven't understood properly.

Enjoy, hope this was explained well and helped :slightly_smiling:


#14

Um thank you but it said it didn't recognize the "else" factor. Please help :confused: but thank you for everything else.


#15

Thank you. Would you happen to know the "else" factor?


#16

It's because else needs a default value, you can't make it check/compare anything so it would be

} else {
console.log("oh no I'm broken");
}


#17

Ok thank you a lot..


#18

What? That doesn't make any sense.


#19

Which part makes no sense?