Skip to content

Instantly share code, notes, and snippets.

@afandiyusuf
Created October 4, 2019 14:37
Show Gist options
  • Save afandiyusuf/1bee6419f0f3c2ed3b4bf0ddc278348c to your computer and use it in GitHub Desktop.
Save afandiyusuf/1bee6419f0f3c2ed3b4bf0ddc278348c to your computer and use it in GitHub Desktop.
Levelling Discount
function getRealDiscount(stringDiscount){
var real_discount = 0;
var a = stringDiscount.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]
}
}
real_discount += x/100*a[i];
}
return real_discount;
}
getRealDiscount("10+20+30");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment