I want my foreach() to loop through an array of maps and check if the type value matches. If not return the else statement.
Function
function checkCars(carData) {
const cars = carData.models;
models.forEach(model => {
if (model.type === 'Toyota' || model.type === 'Hyundai') {
return "Type A";
} else {
return "Type B";
}
});
}
Database
"models": [
{type: "Toyota"}
{type: "Hyundai"}
{type: "Audi"}
{type: "VW"}
]