Given the following code, which works, and prints out all colors that are red, why does it also print out an undefined value at the end of the interations?
var cars is just a large array of car-objects with various properties.
function queryCars(){
// Your code here
for (var i = 0; i < cars.length; i++ ){
if(cars[i].color == "Red") {
console.log(cars[i].make + " " + cars[i].model)
}
}
}
Result:
queryCars();
"Audi A5"
"Audi TT"
"BMW 3"
"BMW X5"
"Hyundai Elantra"
"Acura TLX"
undefined