Created
October 4, 2019 13:46
-
-
Save afandiyusuf/7f1e4ef58579af9b02c2632e1a89dc7e to your computer and use it in GitHub Desktop.
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 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