Ask coding questions

← Back to all posts
help me with my assignment
robertarroyo87 (0)

Can someone help me with my assignment? Im new at coding. I Need help with question 3. I have tried everything and every video. I just can't figure it out.

Commentshotnewtop
mwilki7 (424)

What does question 3 say?

robertarroyo87 (0)

@mwilki7
Function exerciseThree(STR)
In this exercise you will be given a variable, it will be called: str
On the next line create a variable called 'lenght' and using the length property assign the str

mwilki7 (424)

@robertarroyo87
Strings in JavaScript have a property called "length" obviously to tell you how long a word is.

The videos you've seen have probably told you this already but,
to access a property of an object attach a period . at the end of the variable name, followed by the name of the property.

In your case you want to .length from str

str.length

You also have a variable called length (a valid name, but it's confusing to use "length" so many times for different things)
var length;
You just want to set length equal to str.length like so:

var length;
length = str.length;