javascript: calculate x% of a number

Hailwood picture Hailwood · Dec 7, 2010 · Viewed 178.2k times · Source

I am wondering how in javascript if i was given a number (say 10000) and then was given a percentage (say 35.8%)

how would I work out how much that is (eg 3580)

Answer

alex picture alex · Dec 7, 2010
var result = (35.8 / 100) * 10000;

(Thank you jball for this change of order of operations. I didn't consider it).