# Adding numbers inside an array

**URL:** <https://forum.kirupa.com/t/adding-numbers-inside-an-array/171194>\
**Category:** flash\
**Created:** [December 2, 2005, 5:17pm UTC](https://forum.kirupa.com/t/adding-numbers-inside-an-array/171194 "2005-12-02T17:17:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ryguyspk](https://avatars.discourse-cdn.com/v4/letter/r/71c47a/32.png) [@ryguyspk](https://forum.kirupa.com/u/ryguyspk)\
**Post date:** [December 2, 2005, 5:17pm UTC](https://forum.kirupa.com/t/adding-numbers-inside-an-array/171194/1 "2005-12-02T17:17:25Z")

</div>

I am generating an array dynamically with numbers. When I loop through the array, I’m trying to add the numbers up. I know I’m missing something because this code is adding each value twice instead of the whole array of numbers… what am I missing?

It should add up to 100.

```php

var buildArr:Array = [10, 20, 30, 40];
	
	for (i=0; i<=buildArr.length-1; i++) {
		var total:Number = buildArr* + buildArr*
		trace('total: '+total);
	}

```

This works here:

```php

numberArr = new Array(10, 20);
total = numberArr[0]+numberArr[1];
trace(total);

```

However, the number array is based on a user’s input, so that’s why I’m putting it inside of a loop.

Any ideas?
