newbie here.
I'm having trouble with a simple challenge, the goal is simple, push the sedan cars into another array, so the output when the function is called (no console.log can be used, it will be ignored) is:
[ { type:'sedan', size: 'white'} , { type:'sedan', color:'red'} ].
The suggestion is to use push().
Here is my terrible code.
Any help is welcome!
function filterCars (cars) {
const sedanCars = []
const carArr = [
{ type: 'sedan', color: 'white'},
{ type: 'truck', color: 'blue'},
{ type: 'sedan', color: 'red'},
{ type: 'coupe', color: 'red'}
]
var arrayLength = carArr.length;
for (var i = 0; i < arrayLength; i++) {
console.log(carArr[i]);
if(carArr.type==="sedan") {
return sedanCars.push("sedan");
}