FAQ: Introduction to JavaScript - Properties

I created another account and was able to move forward. I’m not sure what the problem was. Thanks

1 Like

I had the same problem. It was my fault, I wrote lenght instead of length.

1 Like

I am having the same issue. I don’t want to create a new account as I have other lessons I am working on. I know the language fairly well as I have created websites before and used Node.js and React so I know that what I am doing is the correct syntax but it’s not taking it. How do I go about forcing the lesson to pass me?

1 Like

11 posts were split to a new topic: Can’t continue without pressing solution button

Hi, i have done what the exercise has asked me to and passed it… But why is it relevant?.. like why would i want to know how many letters are in the sentence?

2 Likes

Seems like a reasonable question. I’ll try to give a reasonable answer. You might be hosting a message board, and have a character limit per post. This forum, for example has a minimum characters per post limit. As you get further along in learning to code, you’ll come to realize that you use the .length property of different objects quite often.

2 Likes

Hello , one basic question :
console.log(“Hello”.length)
.log is a method
.length is a properties

So properties = method ?
else what the difference between ?

A method is an attribute, but that does not make an attribute a method. A method is function, so performs some task. .length is a value, only.

We poll values, and call (or invoke) methods.

hi in this chapter the characters are supposed to be 25 or 30 ?

console.log("Teaching the world how to code".length);

Is that the line you are measuring?

It’s 30 characters because .length counts each space as a character.

m = "23.556"
d = m.substring(m.indexOf('.') + 1).length

I’m having the same problem as everyone else. I’m not able to pass Introduction to JavaScript part 7 (properties).
My code seems to be correct, but it won’t let me pass to the next step (I prefer not to use the solution button).
Here’s a screenshot:

Be sure to check for typos/misspellings.

1 Like

So sorry! I didn’t notice that I misspelt “length”.
It works now. Thank you @mtf.

1 Like

Hello, what would the .length for numbers be, I tried assigning a variable to a number and then putting the variable in the console.log but it returns undefined, thanks fairly new to this.

Numbers are exact values that don’t have a length. Sure they have numeral characters, etc., but as objects they have no length. Further to this, numbers are not iterable.

“When you introduce a new piece of data into a JavaScript program, the browser saves it as an instance of the data type”

Can somebody please explain this concept in simpler terms? Thank you very much

a = 42

Above we assign an integer value (a number) to the variable, a. When we poll the type of a we are actually polling the type of 42. a is not an object, but a reference to an object. 42 is identified by the interpreter as being a number type so gives it a wrapper object of that type.

typeof 42  =>  'number'

typeof a   =>  'number'

So a refers to an instance of a number type.

1 Like

I think I understand it better now, thank you for your explanation sir.

1 Like