Skip to content

Instantly share code, notes, and snippets.

@arathunku
Created January 5, 2016 18:27
Show Gist options
  • Save arathunku/a9062237d6c05489b10d to your computer and use it in GitHub Desktop.
Save arathunku/a9062237d6c05489b10d to your computer and use it in GitHub Desktop.
var result =
Array.prototype.slice.call(document.querySelectorAll('.semester .data')).
map(function(t) {
var td = t.querySelectorAll('td');
return[t.querySelector('[data-title="nazwaKursu"]').innerText,
parseFloat(t.querySelector('[title="ocena"]').innerText, 10),
parseFloat(td[td.length -1 ].innerText, 10)
];
}).reduce(function(r, t) {
return [r[0] + (t[1] * t[2]), r[1] + t[2]]
}, [0, 0]);
console.log("Srednia ważona: ", result[0]/result[1]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment