Skip to content

Instantly share code, notes, and snippets.

@Gimenz
Last active August 3, 2021 14:05
Show Gist options
  • Save Gimenz/ef12c7f2b8944b701cd8f975f3f3ae13 to your computer and use it in GitHub Desktop.
Save Gimenz/ef12c7f2b8944b701cd8f975f3f3ae13 to your computer and use it in GitHub Desktop.
Hitung Cashback
// 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