Skip to content

Instantly share code, notes, and snippets.

@rawsh
Last active December 17, 2017 20:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rawsh/15ea1705d369958f057b4e83e78a56b9 to your computer and use it in GitHub Desktop.
Save rawsh/15ea1705d369958f057b4e83e78a56b9 to your computer and use it in GitHub Desktop.
Sort grades numerically WebAssign (run in js console)
var list = document.querySelectorAll(".scoreBox > p > strong");
var regExp = /\(([^)]+)\)/;
var sgrades = [];
function insert(element, array) {
array.push(element);
array.sort(function(a, b) {
return a - b;
});
return array;
}
for (var i = 0; i < list.length; i++) {
try {
sgrades = insert(parseFloat(regExp.exec(list[i].innerText)[1]), sgrades);
} catch (e) {}
}
console.log(sgrades);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment