# Array length returns incorrect value

**URL:** <https://forum.kirupa.com/t/array-length-returns-incorrect-value/328235>\
**Category:** flash\
**Created:** [April 30, 2012, 12:21pm UTC](https://forum.kirupa.com/t/array-length-returns-incorrect-value/328235 "2012-04-30T12:21:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![panoss](https://avatars.discourse-cdn.com/v4/letter/p/db5fbb/32.png) [@panoss](https://forum.kirupa.com/u/panoss)\
**Post date:** [April 30, 2012, 12:21pm UTC](https://forum.kirupa.com/t/array-length-returns-incorrect-value/328235/1 "2012-04-30T12:21:50Z")

</div>

The code loops from the 1st letter of the string (“123 567”) till the last and finds position of the gaps in it (1, which is correct) and the Array length (= number of gaps =4 which is wrong). What am I doing wrong?

Just copy the code in the 1st frame(flash 8) and run it:

```auto
var s:String = "123 567";
var cl:String = "";		
var gap:Array = new Array();

for(var i:Number = 0; i<s.length; i++){	
	cl = s.charAt(i);
	if(cl == " "){gap* = (i); trace("gap at position " + i );}			
}	

trace("number of gaps =" + gap.length);

```
