# Https://codepen.io/pen/

**URL:** <https://discourse.mozilla.org/t/https-codepen-io-pen/53626>\
**Category:** MDN\
**Created:** [February 9, 2020, 11:33pm UTC](https://discourse.mozilla.org/t/https-codepen-io-pen/53626 "2020-02-09T23:33:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![samcesa45](https://avatars.discourse-cdn.com/v4/letter/s/b9bd4f/32.png) [@samcesa45](https://discourse.mozilla.org/u/samcesa45)\
**Post date:** [February 9, 2020, 11:33pm UTC](https://discourse.mozilla.org/t/https-codepen-io-pen/53626/1 "2020-02-09T23:33:11Z")

</div>

How could solve the loop 2 test

---

<div class="post-metadata">

**Author:** ![chrisdavidmills](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/chrisdavidmills/32/21688_2.png) [@chrisdavidmills](https://discourse.mozilla.org/u/chrisdavidmills)\
**Post date:** [February 10, 2020, 9:13am UTC](https://discourse.mozilla.org/t/https-codepen-io-pen/53626/2 "2020-02-10T09:13:01Z")

</div>

Here is the marking guide for loops 2:

> <https://github.com/mdn/learning-area/blob/master/javascript/building-blocks/tasks/loops/marking.md#task-2>

---

<div class="post-metadata">

**Author:** ![Arthur\_Chen](https://avatars.discourse-cdn.com/v4/letter/a/e99b99/32.png) [@Arthur\_Chen](https://discourse.mozilla.org/u/Arthur_Chen)\
**Post date:** [August 7, 2020, 4:32am UTC](https://discourse.mozilla.org/t/https-codepen-io-pen/53626/3 "2020-08-07T04:32:24Z")

</div>

Hi Chris, I know that you responded to this post a while back in February so you may not see my comment. However, I am confused as to why this code was added to the solution for Task 2.

if(i === phonebook.length - 1) {  
para.textContent = ‘Name not found in the phonebook’;  
}

I don’t understand why this is relevant to the task or why the code in the parentheses needs to be i === phonebook.length - 1. Why are we checking if i is equal to only the last item in the array and not the others?

---

<div class="post-metadata">

**Author:** ![samcesa45](https://avatars.discourse-cdn.com/v4/letter/s/b9bd4f/32.png) [@samcesa45](https://discourse.mozilla.org/u/samcesa45)\
**Post date:** [August 7, 2020, 12:34pm UTC](https://discourse.mozilla.org/t/https-codepen-io-pen/53626/4 "2020-08-07T12:34:21Z")

</div>

If we do not check for i === I.length -1 the loop will go past the last item and return empty.but if we check for the last item it will always go back to the previous item after reaching the last item.add me on discord cesa#9381

---

<div class="post-metadata">

**Author:** ![Arthur\_Chen](https://avatars.discourse-cdn.com/v4/letter/a/e99b99/32.png) [@Arthur\_Chen](https://discourse.mozilla.org/u/Arthur_Chen)\
**Post date:** [August 7, 2020, 5:31pm UTC](https://discourse.mozilla.org/t/https-codepen-io-pen/53626/5 "2020-08-07T17:31:31Z")

</div>

I just added you on discord. Thanks.
