-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
This is more compact and also gives information about the result without executing it:
function vehicleInfo(color, vehicle, years) {
let type = vehicle < 2 ? "car" : vehicle == 2 ? "bike" : "vehicle"
let age = years < 1.5 ? "new" : years <= 4 ? "slightly used" : "used"
return "This is a " + age + " " + color + " " + type
}
assert(vehicleInfo('blue', 1, 1), 'This is a new blue car')
assert(vehicleInfo('red', 2, 2), 'This is a slightly used red bike')
assert(vehicleInfo('yellow', 3, 5), 'This is a used yellow vehicle')
assert(vehicleInfo('green', 1, 1), 'This is a new green car')
assert(vehicleInfo('black', 2, 2), 'This is a slightly used black bike')
Metadata
Metadata
Assignees
Labels
No labels