# My grade calculator with special weighting

My school has a special 65% formal 35% informal weighting, so I made something to find what your grade would be if you added or changed a grade. http://retep-mathwizard.github.io/gradecalc/gradecalc.html

### HTML:

<!DOCTYPE html>
<html>
<meta charset="utf-8"/>
<body>
<input id="ing" placeholder="Informal grades, seperate by commas."><br>
<input id="fog" placeholder="Formal grades, seperate by commas."><br>
</body>
</html>


### CSS:

#fog, #ing {

width: 300px;
}


### JS:

function changeoldgradedisplay() {
} else {
}
}
function get_average(items) {
var sum = 0;
var len = items.length;
for (var i = 0; i < len; i++) {
sum += parseFloat(items[i]);
}
return sum/len;
}

if (is_formal) {
} else {
}
} else {
} else {
}
}

}


A couple of minor things:

• fog and ing aren't very meaningful id names, they would be better as something like formal_grades and informal_grades instead.

• This part of the code:

var is_formal = document.getElementById('formal_radio').checked;

if (is_formal) {
} else {
}
} else {
} else {
}
}


repeats very similar code where the only difference is which array is used. Also, gradelist isn't used anywhere. You can avoid the repetition like this:

var is_formal = document.getElementById('formal_radio').checked;


by assigning the array that needs to be used to gradelist.
This works because when you assign an array (or any object) to a variable in javascript, it assigns the reference to the array instead of copying the value. For example, if formal_grades is assigned to gradelist they will both refer to the same array.
• Also, I thought of assigning a gradelist, but later I recalculate using both lists, and I couldn't differentiate between the 2. (var new_grade = (get_average(formal_grades) * .65) + (get_average(informal_grades) * .35);) – lol Jan 19 '17 at 17:24