Grade calculator in javascript