Created
January 2, 2018 01:44
-
-
Save garybunofsky/85a6604a6e9d25046d53afe5ae789e3e to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/solepek
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
// Write a function called newCars | |
// that returns an array of cars | |
// newer than the year 2000. | |
var carList = [ | |
{ | |
make: 'chevy', | |
year: 1968 | |
}, | |
{ | |
make: 'bmw', | |
year: 2012 | |
}, | |
{ | |
make: 'toyota', | |
year: 1994 | |
}, | |
{ | |
make: 'jeep', | |
year: 1999 | |
}, | |
{ | |
make: 'jaguar', | |
year: 2015 | |
}, | |
{ | |
make: 'nissan', | |
year: 2016 | |
} | |
]; | |
function newCars(carList) { | |
var newCars = []; | |
carList.forEach(function(car) { | |
if(car.year > 2000){ | |
newCars.push(car); | |
} | |
}); | |
return newCars; | |
} | |
console.log(newCars(carList)); | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">// Write a function called newCars | |
// that returns an array of cars | |
// newer than the year 2000. | |
var carList = [ | |
{ | |
make: 'chevy', | |
year: 1968 | |
}, | |
{ | |
make: 'bmw', | |
year: 2012 | |
}, | |
{ | |
make: 'toyota', | |
year: 1994 | |
}, | |
{ | |
make: 'jeep', | |
year: 1999 | |
}, | |
{ | |
make: 'jaguar', | |
year: 2015 | |
}, | |
{ | |
make: 'nissan', | |
year: 2016 | |
} | |
]; | |
function newCars(carList) { | |
var newCars = []; | |
carList.forEach(function(car) { | |
if(car.year > 2000){ | |
newCars.push(car); | |
} | |
}); | |
return newCars; | |
} | |
console.log(newCars(carList)); | |
</script></body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Write a function called newCars | |
// that returns an array of cars | |
// newer than the year 2000. | |
var carList = [ | |
{ | |
make: 'chevy', | |
year: 1968 | |
}, | |
{ | |
make: 'bmw', | |
year: 2012 | |
}, | |
{ | |
make: 'toyota', | |
year: 1994 | |
}, | |
{ | |
make: 'jeep', | |
year: 1999 | |
}, | |
{ | |
make: 'jaguar', | |
year: 2015 | |
}, | |
{ | |
make: 'nissan', | |
year: 2016 | |
} | |
]; | |
function newCars(carList) { | |
var newCars = []; | |
carList.forEach(function(car) { | |
if(car.year > 2000){ | |
newCars.push(car); | |
} | |
}); | |
return newCars; | |
} | |
console.log(newCars(carList)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment