# Basic JavaScript - Iterate Through an Array with a For Loop

**URL:** <https://forum.freecodecamp.org/t/basic-javascript-iterate-through-an-array-with-a-for-loop/594009>\
**Category:** Curriculum Help\
**Created:** [February 22, 2023, 6:10pm UTC](https://forum.freecodecamp.org/t/basic-javascript-iterate-through-an-array-with-a-for-loop/594009 "2023-02-22T18:10:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cjh18200](https://avatars.discourse-cdn.com/v4/letter/c/35a633/32.png) [@cjh18200](https://forum.freecodecamp.org/u/cjh18200)\
**Post date:** [February 22, 2023, 6:10pm UTC](https://forum.freecodecamp.org/t/basic-javascript-iterate-through-an-array-with-a-for-loop/594009/1 "2023-02-22T18:10:29Z")

</div>

**Tell us what’s happening:**  
Describe your issue in detail here. I thought i should pop the array elements and add them to total…seems to be more difficult than i anticipated

**Your code so far**

```javascript
// Setup
const myArr = [2, 3, 4, 5, 6];

// Only change code below this line

for (let i = 0; i <= myArr.length ; i ++) {

const total = myArr.pop(i) ; console.log(total)
  
}

```

**Your browser information:**

User Agent is: `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36`

**Challenge:** Basic JavaScript - Iterate Through an Array with a For Loop

**Link to the challenge:**

> **[freeCodeCamp.org](https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/iterate-through-an-array-with-a-for-loop)**
>
> Learn to Code — For Free

---

<div class="post-metadata">

**Author:** ![cjh18200](https://avatars.discourse-cdn.com/v4/letter/c/35a633/32.png) [@cjh18200](https://forum.freecodecamp.org/u/cjh18200)\
**Post date:** [February 24, 2023, 3:37am UTC](https://forum.freecodecamp.org/t/basic-javascript-iterate-through-an-array-with-a-for-loop/594009/3 "2023-02-24T03:37:51Z")

</div>

yeah i tried to work off of memory

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/freecodecamp/original/3X/e/1/e1c433102e34b46dfaa3e15d13ab9a514b127078.svg) [@system](https://forum.freecodecamp.org/u/system)\
**Post date:** [August 25, 2023, 3:38pm UTC](https://forum.freecodecamp.org/t/basic-javascript-iterate-through-an-array-with-a-for-loop/594009/4 "2023-08-25T15:38:50Z")

</div>

Closed on August 25, 2023, 3:38pm UTC

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.
