JavaScript undefined issue, not sure why
I get the result: Your new car is a undefined undefined undefined in my console with JavaScript. Here is the code: function makeCar(){ var makes = ['chevy', 'vw', 'toyota', 'fiat']; var models = ['aveo', 'beetle', 'etios', 'uno']; var years = [2009, 1965, 2013, 1999]; var colors = ['red', 'blue', 'yellow', 'purple', 'grey']; var convertible = [true, false]; var rand1 = Math.floor(Math.random() * makes.length); var rand2 = Math.floor(Math.random() * models.length); var rand3 = Math.floor(Math.random() * years.length); var rand4 = Math.floor(Math.random() * colors.length); var rand5 = Math.floor(Math.random() * 5) + 1; var rand6 = Math.floor(Math.random() * 2); var car = { makes: makes[rand1], models: models[rand2], years: years[rand3], colors: colors[rand4], passengers: rand5, convertible: convertible[rand6], mileage: 0 }; return car; } function displayCar(car){ console.log("Your new car is a " + car.year + " " + car.make + " " + car.model); } var carToSell = makeCar(); displayCar(carToSell);