Skip to content

Instantly share code, notes, and snippets.

@afandiyusuf
Created October 4, 2019 13:46
Show Gist options
  • Save afandiyusuf/7f1e4ef58579af9b02c2632e1a89dc7e to your computer and use it in GitHub Desktop.
Save afandiyusuf/7f1e4ef58579af9b02c2632e1a89dc7e to your computer and use it in GitHub Desktop.
function cekDiskonAsli(string){
var diskon_asli = 0;
var a = string.split('+');
for(var i=0;i<a.length;i++)
{
var x = 100;
if(i != 0)
{
for(var j =0;j<i;j++)
{
x -= a[j]
}
}
diskon_asli += x/100*a[i];
}
return diskon_asli;
}
cekDiskonAsli("10+20+30");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment