# Loop Being Bypassed?

**URL:** <https://forum.freecodecamp.org/t/loop-being-bypassed/451314>\
**Category:** Curriculum Help\
**Tags:** javascript\
**Created:** [March 16, 2021, 1:36am UTC](https://forum.freecodecamp.org/t/loop-being-bypassed/451314 "2021-03-16T01:36:43Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![kmkelly02](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/kmkelly02/32/209836_2.png) [@kmkelly02](https://forum.freecodecamp.org/u/kmkelly02)\
**Post date:** [March 16, 2021, 1:36am UTC](https://forum.freecodecamp.org/t/loop-being-bypassed/451314/1 "2021-03-16T01:36:43Z")

</div>

All of my individual components in the code below work perfectly. I have console.logged the loop, if I remove the function call for the second function from the first the numbers do not appear, and the second function returns the numbers joined by a space and a comma. However, my loop does not appear to be working as it only returns one group of numbers.

```auto
<html>

<body>

<p>Click the button to display a random number.</p>

<button onclick="pballmultiple()">Try it</button>

<p id="demo"></p>

<script>

function pballmultiple() {

for (var j = 0; j < 5; j++) { 

pballnumbers();

}  

}

function pballnumbers() {

var pballnums =[];  

for (var i = 0; i < 5; i++) { 

var randomNumber= Math.floor(Math.random() * 69)+1;

pballnums.push(randomNumber);

  document.getElementById("demo").innerHTML = pballnums.join(" - ");

}

}
![Index|450x500](upload://48m3vndgS9VUTxIMsel4BUI1R4u.png) 
</script>

</body>

</html>

```

 ![Index](https://global.discourse-cdn.com/freecodecamp/original/3X/1/c/1cfa7f3c485f60b0b3cb33e1b8853485e0525be2.png)

---

<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:** [March 16, 2021, 3:53am UTC](https://forum.freecodecamp.org/t/loop-being-bypassed/451314/2 "2021-03-16T03:53:20Z")

</div>

Is there supposed to be a link?

---

<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:** [March 16, 2021, 4:20am UTC](https://forum.freecodecamp.org/t/loop-being-bypassed/451314/3 "2021-03-16T04:20:05Z")

</div>

> [@kmkelly02](#):
>
> ![Index](https://global.discourse-cdn.com/freecodecamp/original/3X/1/c/1cfa7f3c485f60b0b3cb33e1b8853485e0525be2.png)

I’m only quoting because the image is not displaying properly for me

---

<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:** [March 16, 2021, 4:35am UTC](https://forum.freecodecamp.org/t/loop-being-bypassed/451314/4 "2021-03-16T04:35:57Z")

</div>

Could you change the format of your code to text, and also explain the expected behavior of the code

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [March 16, 2021, 7:00am UTC](https://forum.freecodecamp.org/t/loop-being-bypassed/451314/5 "2021-03-16T07:00:14Z")

</div>

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (`</>`) to add backticks around text.

 ![Pre-formatted-text](https://global.discourse-cdn.com/freecodecamp/original/3X/1/b/1b18854f1059217f29370444396145cc3a0cd8ae.gif)

See [this post](https://forum.freecodecamp.org/t/forum-code-formatting/25574) to find the backtick on your keyboard.  
**Note:** Backticks (`) are not single quotes (’).

---

<div class="post-metadata">

**Author:** ![DanCouper](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/dancouper/32/158608_2.png) [@DanCouper](https://forum.freecodecamp.org/u/DanCouper)\
**Post date:** [March 16, 2021, 9:23am UTC](https://forum.freecodecamp.org/t/loop-being-bypassed/451314/6 "2021-03-16T09:23:38Z")

</div>

> [@kmkelly02](#):
>
> However, my loop does not appear to be working as it only returns one group of numbers.

You’re replacing everything on each iteration: `innerHTML` just replaces whatever was there before with what you specify

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [August 12, 2022, 2:32pm UTC](https://forum.freecodecamp.org/t/loop-being-bypassed/451314/7 "2022-08-12T14:32:13Z")

</div>

Closed on August 12, 2022, 2:32pm UTC


