1

Google wasn't my friend on this one... maybe I wasn't searching for the right terms.

I have a javascript array randomTagLine[0], randomTagLine[1], etc. How do I get the total number of variables in the array? For instance, I can physically see there are 23, but I need to pull that out via JS code...

Thanks in advance..

EDIT

Example of code:

var randomTagline = new Array();
randomTagline[0] = "TEXT0";
randomTagline[1] = "TEXT1";
randomTagline[2] = "TEXT2";
//...
randomTagline[23] = "TEXT23";
var randomTaglineLength = randomTagLine.length;

var randomTaglineNum = randomXToY(0,randomTaglineLength,0);

alert(randomTaglineNum + " " + randomTaglineLength);

1 Answer 1

5

It's :

 var length = randomTagLine.length;
Sign up to request clarification or add additional context in comments.

4 Comments

I'm getting a randomTagLine is not defined on that, even though it's defined earlier as var randomTagline = new Array(); any ideas?
Can you post a little more code ? Like for example, where are you defining the array, filling it, and testing the length ?
Found it... it was an "L" instead of a "l"... Thanks for your help!
You got it like 2 seconds before me :p

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.