My code passes, but is significantly different from the two solutions on the challenge guide post. I’m just hoping for some constructive feedback on my implementation.
**Your code so far**
const result = {
success: ["max-length", "no-amd", "prefer-arrow-functions"],
failure: ["no-var", "var-on-top", "linebreak"],
skipped: ["no-extra-semi", "no-dup-keys"]
};
function makeList(arr) {
// Only change code below this line
const failureItems = [];
for (let i = 0; i < arr.length; i++) {
failureItems[i] = `<li class="text-warning">${result.failure[i]}</li>`;
}
// Only change code above this line
return failureItems;
}
const failuresList = makeList(result.failure);
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.61 Safari/537.36
All of the code are doing the same thing. They all use loops (but the last hides it in a map). The first one appends the new element, but yours places it at a specific index - in this context, they do the same thing. Which is better? Between those two, in this situation, I don’t think it really matters. Of the three, I like the map one the best, as it hides a lot of the details and is the most semantically explicit. In the “real world” that would probably be simplified to:
But be happy, you solved the problem. These are all doing the same thing algorithmically, they all solve the problem the same way, it’s just different implementations of the peculiarities of the language. You can learn all those little slick tricks later, the “thinking through the problem and coming up with a solution” is the most important thing you are learning right now.