Skip to content

Instantly share code, notes, and snippets.

@nadeesha
Last active June 16, 2019 23:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nadeesha/0c6327bcfa41310661842fb55d82484e to your computer and use it in GitHub Desktop.
Save nadeesha/0c6327bcfa41310661842fb55d82484e to your computer and use it in GitHub Desktop.
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)
}
}
@andria-dev
Copy link

There's a typo here:

You wrote getCarCofig that should be getCarConfig

@nadeesha
Copy link
Author

Thanks @ChrisBrownie55. Corrected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment