Created
November 7, 2019 21:14
-
-
Save zzdjk6/d78e7aa3ec96d707a5df6777222230d6 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 discount1 = (price, discount) => { | |
| const final = price * (1 - discount); | |
| console.log(`V1 -- Original Price: ${price}, Discount: ${discount}, Final Price: ${final}`); | |
| } | |
| discount1(500, 0.5); | |
| discount1(400, 0.5); | |
| discount1(300, 0.5); | |
| const halfPrice1 = price => discount1(price, 0.5); | |
| halfPrice1(500); | |
| halfPrice1(400); | |
| halfPrice1(300); | |
| const discount2 = discount => price => { | |
| const final = price * (1 - discount); | |
| console.log(`V2 -- Original Price: ${price}, Discount: ${discount}, Final Price: ${final}`); | |
| } | |
| const halfPrice2 = discount2(0.5); | |
| // const halfPrice2 = price => discount2(0.5)(price); | |
| halfPrice2(500); | |
| halfPrice2(400); | |
| halfPrice2(300); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://jsbin.com/novoduq/1/edit?js,console