Created
July 21, 2018 17:13
-
-
Save gzagatti/820e241edfb2aa6ab0f4a0ce19323797 to your computer and use it in GitHub Desktop.
Performs basic analysis on a random table found in a webpage using basic JS
This file contains hidden or 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
// Before proceeding add an ID `target` to the table you want to perform the analysis on | |
// Google Chrome intercepts $ as a shortcut for document.querySelector() and | |
// $$() as a shortcut for document.querySelectorAll() | |
items = [] | |
$$('#target tr').forEach( | |
(row) => items.push( | |
parseFloat( | |
$$('td p font', row)[3].innerHTML.replace(/,/g, '.')) | |
) | |
) | |
// remove header | |
items = items.slice(1) | |
// average it out | |
items.reduce((a, b) => a + b) / items.length |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment