I have been using Scrimba to write this code in React, but it doesn’t work. I don’t know why, and would appreciate your help in figuring it out!
function App() {
let todoItems = "";
let maxNumber = 4;
while(maxNumber !== 0){
maxNumber--;
todoItems = todoItems + <TodoItem />;
}
return (
<div>
<ul>
{todoItems}
</ul>
</div>
)
}
The objective of this code is to return the same component (<TodoItem />
) 4 times. But instead of seeing the components, my scrimba preview shows this:
Link to my code: https://scrimba.com/c/cbqPLzUa