001function getCars() {
002 return [
003 {
004 doors:4,
005 colour:'red',
006 drive: function()
007 {
008 'Running 20mp'
009 }
010 },
011 {
012 doors:2,
013 colour:'blue',
014 drive: function()
015 {
016 'Running 20mp'
017 }
018 },
019 {
020 doors:5,
021 colour:'yellow',
022 drive: function()
023 {
024 'Running 20mp'
025 }
026 }
027 ];
028};
029
030function displayCar(CARS)
031{
032
033 let carObjectsAsString = '';
034
035 CARS.forEach(function(car)
036 {
037
038 if(car.colour == 'yellow')
039
040 for(let carData in car)
041 {
042
043 carObjectsAsString+=carData +': ' + car[carData] + '\n';
044 }
045 });
046
047 console.log(carObjectsAsString);
048}
049
050window.onload = function(){
051 const CARS = getCars();
052
053 const yellowCar = CARS.filter(car => car.colour == 'yellow');
054 displayCar(CARS);
055}
056
057