Answer the question
In order to leave comments, you need to log in
Does the example code not work?
I am making an application in React, when iterating over an array using the map method, inside it I also iterate over the object using the for loop, and inside there are also conditions. But for some reason, it swears that there is a for loop or if or switch conditions in curly braces. Although this design works outside of this component.
<TableBody>
{cars.map((car, index) => (
<TableRow key={index}>
<TableCell>{`${car.mark} ${car.model}`}</TableCell>
{
for (let key in car.tariffs) {
switch (key) {
case 'Стандарт':‹
return <TableCell>{key.year}</TableCell>;
case 'Комфорт':
return <TableCell>{key.year}</TableCell>;
case 'Бизнес':
return <TableCell>{key.year}</TableCell>;
case 'Комфорт+':
return <TableCell>{key.year}</TableCell>;
case 'Эконом':
return <TableCell>{key.year}</TableCell>;
case 'Минивэн':
return <TableCell>{key.year}</TableCell>;
case 'Лайт':
return <TableCell>{key.year}</TableCell>;
default:
return <TableCell>-</TableCell>;
}
}
}
</TableRow>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question