# Assessment wanted for Loops 1, 2, and 3 skill test

**URL:** <https://discourse.mozilla.org/t/assessment-wanted-for-loops-1-2-and-3-skill-test/93162>\
**Category:** Learn\
**Created:** [February 15, 2022, 6:05pm UTC](https://discourse.mozilla.org/t/assessment-wanted-for-loops-1-2-and-3-skill-test/93162 "2022-02-15T18:05:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![superpav](https://avatars.discourse-cdn.com/v4/letter/s/7c8e57/32.png) [@superpav](https://discourse.mozilla.org/u/superpav)\
**Post date:** [February 15, 2022, 6:05pm UTC](https://discourse.mozilla.org/t/assessment-wanted-for-loops-1-2-and-3-skill-test/93162/1 "2022-02-15T18:05:31Z")

</div>

Hi all!

Can someone please take a look at my solutions for loop exercises in the [respective section](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/Test_your_skills:_Loops) on mdn?  
Did I miss anything? Anything I should improve?  
Here are the codepens:  
Loop 1 exercise: [https://codepen.io/fantazzista/pen/dyZVBzp](https://codepen.io/fantazzista/pen/dyZVBzp)  
Loop 2 exercise: [https://codepen.io/fantazzista/pen/xxPXoWw](https://codepen.io/fantazzista/pen/xxPXoWw)  
Loop 3 exercise: [https://codepen.io/fantazzista/pen/MWOEMVR](https://codepen.io/fantazzista/pen/MWOEMVR)

Thanks in advance for your time.

---

<div class="post-metadata">

**Author:** ![mikoMK](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/mikomk/32/50456_2.png) [@mikoMK](https://discourse.mozilla.org/u/mikoMK)\
**Post date:** [February 16, 2022, 2:16pm UTC](https://discourse.mozilla.org/t/assessment-wanted-for-loops-1-2-and-3-skill-test/93162/2 "2022-02-16T14:16:10Z")

</div>

Hi @superpav and welcome to the community 👋

You did great 🏅

Here are my comments:  
Task 1: Correct ✅ You could just use `=` instead of `+=` since you are redefining `bulletpoint` at the start of every loop.  
Task 2: Correct ✅  
Task 3: Correct ✅ Simplification: You can delete the first half of your loop. This is enough:

```auto
if (isPrime(i)) {
  para.textContent += `${i} `
}

```

Keep up the good work and have a nice day 🙂  
Michael

---

<div class="post-metadata">

**Author:** ![superpav](https://avatars.discourse-cdn.com/v4/letter/s/7c8e57/32.png) [@superpav](https://discourse.mozilla.org/u/superpav)\
**Post date:** [February 16, 2022, 3:00pm UTC](https://discourse.mozilla.org/t/assessment-wanted-for-loops-1-2-and-3-skill-test/93162/3 "2022-02-16T15:00:20Z")

</div>

Thank you Michael.  
As for the 3rd task, I guess I took the line ‘for each number that isn’t a prime number, continue on to the next loop iteration’ too literally 😄

Take care!

---

<div class="post-metadata">

**Author:** ![superpav](https://avatars.discourse-cdn.com/v4/letter/s/7c8e57/32.png) [@superpav](https://discourse.mozilla.org/u/superpav)\
**Post date:** [February 16, 2022, 9:58pm UTC](https://discourse.mozilla.org/t/assessment-wanted-for-loops-1-2-and-3-skill-test/93162/4 "2022-02-16T21:58:13Z")

</div>

For those interested, I think I found another way of writing the third loop. Because the line “For each number that isn’t a prime number, continue on to the next loop iteration” kind of implies that you need to use ‘continue’ in the loop. I guess continue is potentially useful if we want to decrease nesting in a loop. The result remains the same as in previous solutions, but the logic is a little bit different.

```
for (let i = 500; i >= 2; i--) {
      if (!isPrime(i)) continue;
      para.textContent += `${i} `;
    }
```
