# Iterating Integers With No Commas

**URL:** <https://forum.freecodecamp.org/t/iterating-integers-with-no-commas/448492>\
**Category:** Curriculum Help\
**Tags:** javascript\
**Created:** [February 26, 2021, 2:02am UTC](https://forum.freecodecamp.org/t/iterating-integers-with-no-commas/448492 "2021-02-26T02:02:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![CodingPro](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/codingpro/32/134249_2.png) [@CodingPro](https://forum.freecodecamp.org/u/CodingPro)\
**Post date:** [February 26, 2021, 2:02am UTC](https://forum.freecodecamp.org/t/iterating-integers-with-no-commas/448492/1 "2021-02-26T02:02:29Z")

</div>

Hello,

I’ve tried many ways to iterate and sum an integer with no commas. Below was my most recent effort to at least access it and loop through, but I still can’t figure it out. Please help.

```auto
let nums = 4444444;
let splitNums = Number(nums.toString().split(" "))
console.log(splitNums)

```

---

<div class="post-metadata">

**Author:** ![caryaharper](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/caryaharper/32/209142_2.png) [@caryaharper](https://forum.freecodecamp.org/u/caryaharper)\
**Post date:** [February 26, 2021, 4:46am UTC](https://forum.freecodecamp.org/t/iterating-integers-with-no-commas/448492/2 "2021-02-26T04:46:20Z")

</div>

`let splitNums = nums.toString().split("")` this will create an array of the numbers, currently you have a space in your `split` method so what you are actually doing is creating an array that looks like this `["4444444"]` and then you are running calling the number constructor on it, and that normally return `NaN` on an array, but you only have one element so it its just calling it on that instead so the short and sweet of it is all you are doing is making `splitNums` have the same value as `nums`.

---

<div class="post-metadata">

**Author:** ![caryaharper](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/caryaharper/32/209142_2.png) [@caryaharper](https://forum.freecodecamp.org/u/caryaharper)\
**Post date:** [February 26, 2021, 4:47am UTC](https://forum.freecodecamp.org/t/iterating-integers-with-no-commas/448492/3 "2021-02-26T04:47:46Z")

</div>

If you use my method it will look like this `["4", "4", "4", "4", "4", "4", "4"]`

---

<div class="post-metadata">

**Author:** ![CodingPro](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/codingpro/32/134249_2.png) [@CodingPro](https://forum.freecodecamp.org/u/CodingPro)\
**Post date:** [February 27, 2021, 7:56pm UTC](https://forum.freecodecamp.org/t/iterating-integers-with-no-commas/448492/4 "2021-02-27T19:56:05Z")

</div>

That was the problem I kept having. I just ended up creating an array using the method below.

```auto
Array.from(convertString)

```

---

<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 29, 2021, 7:56am UTC](https://forum.freecodecamp.org/t/iterating-integers-with-no-commas/448492/5 "2021-08-29T07:56:20Z")

</div>

Closed on August 29, 2021, 7:56am UTC

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