Last active
December 17, 2017 20:33
-
-
Save rawsh/15ea1705d369958f057b4e83e78a56b9 to your computer and use it in GitHub Desktop.
Sort grades numerically WebAssign (run in js console)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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