Reputation: 223
I've got some Excel formulas. Something like this:
13,7%/(33.3%/6.0%)*100%
How can I do this in Javascript?
Thanx in advance!
Freek
Upvotes: 1
Views: 242
Reputation: 154828
You could have a regexp replacing all occurences with /100
.
var str = "13.7% + 50%/3%",
regexp = /([0-9]*\.?[0-9]*)\%/;
while(regexp.test(str)) str = str.replace(regexp, "($1/100)")
// "(13.7/100) + (50/100)/(3/100)"
Upvotes: 0
Reputation: 19496
just treat the numbers as decimals instead of percentages
var x = .137/(.333/.06)*100
Then format the result with a % to display it.
Upvotes: 4