You are right. This task is tricky, because we don’t know much about loops and functions, yet. Those things are often used together, but we can only teach one thing after the other. I’m sure everything will get clearer when you’ve worked through those lessons.
It was a great idea to look it up somewhere else and then adapt the example. That’s something you will do often when working on a (real) project and this is how we finally get better. The important thing is that we try to understand the code we use from somewhere else.
Generally, you can always come here and ask, if you’re stuck with a task. We gladly give you some hints/explanations to get you further.
That being said, I’m sure you’re relieved to hear that both tasks are correctly solved.
I’m sure you will! There are a few more array function that also work through all elements like forEach(). Once you understand the concept they are a really cool way to work with arrays.