Created
June 8, 2019 20:17
-
-
Save igeligel/5d09207609298dd1b28fcf2729b3a320 to your computer and use it in GitHub Desktop.
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
const vehicles = [ | |
"Airbus A333-300", | |
"Volkswagen Golf", | |
"Porsche Cayenne", | |
"Airbus A380-800" | |
]; | |
const vehiclesWithTypes = vehicles.map(vehicle => { | |
switch (vehicle) { | |
case "Airbus A380-800": | |
case "Airbus A333-300": | |
return { | |
name: vehicle, | |
type: "airplane" | |
}; | |
break; | |
case "Volkswagen Golf": | |
case "Porsche Cayenne": | |
return { | |
name: vehicle, | |
type: "car" | |
}; | |
default: | |
return { | |
name: vehicle, | |
type: null | |
}; | |
} | |
}); | |
console.log(vehiclesWithTypes) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment