Last active
June 16, 2019 23:27
-
-
Save nadeesha/0c6327bcfa41310661842fb55d82484e 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 hasGoodRating = rating => rating > 4; | |
const priceChange = conditionally({ | |
if: hasGoodRating, | |
then: rating => 1000 * rating, | |
else: () => 1000, | |
}); | |
const getDescription = conditionally({ | |
if: hasGoodRating, | |
then: () => "good car", | |
else: () => "bad car", | |
}); | |
function getCarConfig (car) { | |
return { | |
newPrice: priceChange(car.rating) + car.price, | |
description: getDescription(car.rating) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks @ChrisBrownie55. Corrected.