Last active
August 3, 2021 14:05
-
-
Save Gimenz/ef12c7f2b8944b701cd8f975f3f3ae13 to your computer and use it in GitHub Desktop.
Hitung Cashback
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
// source https://nilaimutlak.id/cara-menghitung-diskon/ | |
/** | |
* JavaScript Code Snippet | |
* Online Shop Cashback Counter | |
* | |
* Copyright 2021, Muhamad Ristiyanto | |
* Licensed under The MIT License | |
* http://www.opensource.org/licenses/mit-license | |
* | |
*/ | |
function cashbackCounter(cb, price) { | |
return 'Rp. ' + Number((cb / 100) * price).toLocaleString('id'); | |
} | |
/** | |
* example: | |
* the cashback is 50%, and the price is IDR 30.000 | |
* console.log(cashbackCounter(50, 30000)); // 'Rp. 15.000' | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment