I think part of your problem is const resultDisplayArray twice. Within the function, you may want to just bind an empty array to a different variable, and then have it return that variable.
function makeList(arr) {
"use strict";
let arrayOfList = [];
for (var i = 0; i < result.failure.length; i++) {
// arrayOfList.push("your list items");
}
return arrayOfList;
Your <li> </li> should also be wrapped in backticks.
Or you could use map instead, you are looping over an array and at the same time you are assigning the loop to a variable and not the result of the loop, that’s syntactically wrong. instead you could use map like this
remember map is an array function that iterates over the array and returns a new array. also, do not forget to include the key attribute in your <li> tag because react require a unique index in list
Yeah, I saw everybody using map to do this challenge so I wanted to do it different way. I thought that it may not work as for is inside "const resultDisplayArray " but I hoped you have some workaround to specifically use “for”
I somehow can’t go natural with using map so I always try to find “the other way”.
You can assign expressions to variables (ie things return a value). A for loop is a statement, it returns no value. So const resultDisplayArray = for (let i =.... makes no sense. But you’ve already done basic JS, which has several examples of how to do this:
const resultDisplayArray = [];
for (let i = 0; i < result.failure.length; i++){
resultDisplayArray.push(`<li class="text-warning">${result.failure[i]}</li>`);
}
return resultDisplayArray;