Proportionality Calculator in JavaScript