Created
October 4, 2019 14:37
-
-
Save afandiyusuf/1bee6419f0f3c2ed3b4bf0ddc278348c to your computer and use it in GitHub Desktop.
Levelling Discount
This file contains 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
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