ES6 Day 2 Question

Thanks in advanced for your assistance, I am excited to be learning with you all :slight_smile:

When Ramón put the for loop on the template literals exercise pictured below:

How does Javascript know we are referencing “failure” from the object, and not “success” or “skipped”? It outputs, no-var, var-on-top, and linebreak from the “failure” array which greatly confuses me.

It looks like it should be looping through success, then failure, then skipped. Yet, somehow when the for loop is made, immediately it is already in the right spot for the exercise. Is there something I am not seeing behind the scenes? Please help!

This is really confusing me, and I would like to continue with the lesson but not until I fully understand the start of this exercise. Much gratitude and thanks again!

3 Likes

Hi Tyler, I can’t tell exactly which exercise this is at a glance, because the title is missing. What I am pretty sure is happening, though, is that only the failure array is being passed to the makeList function (I can’t see for sure, because it’s also scrolled off the screen).

4 Likes

You are right, I checked with some friends and out of the picture is line 16 which is passing failure to the function. I was so tunnel visioned above line 16 I missed this completely. Thank you!

3 Likes

Hey Tyler! If I remember correctly, it’s pretty much what @stevenr2945563 said!

2 Likes

Hi @tylers2924003

Sometimes we focus too much in a particular tree (the first solution it come out into your brain) that we don’t see the forest (steps we need to do to reach a final solution). I found really helpful focus only in the question at first and don’t let my brain jump into fast conclusions. I think that a better understanding of the question is like a 70% of the solution.

It helps take an step back after 5-10 min trying to figure out the solution or approach and do something else witch won’t require actual work to your brain: listen music, doing the dishes, walk,…

And after back to problem, or even next day, everything is fine.

Happy coding and well done!!

4 Likes

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