So… I don’t get it. Mine function works. Everything is correct. The last 3 modules have come back erroneous every time I get it correct.
Hello @jesserichey857416700, welcome to the forums! Try putting the
newArr variable inside the
convertToBaby() function. This way, each time the function is called, you will be using an empty array to start. If I ran your code twice, I would get:
console.log(covertToBaby(["mouse", "elephant"])); //prints ["baby mouse", "baby elephant"] console.log(convertToBaby(["mouse", "zebra"])); //prints ["baby mouse", "baby elephant", "baby mouse", "baby zebra"]
Aside, you should use
var when declaring the iterable variable
i in your
for (let i in oldArr)
Yes I noticed that when I was looking at other examples. I have since fixed that issue with my coding in all subsequent functions. Thank you for pointing it out.