Skip to content

Instantly share code, notes, and snippets.

@nickcaballero
Last active March 3, 2021 23:56
Show Gist options
  • Save nickcaballero/dbf52dea7b549a588e50c3500483d694 to your computer and use it in GitHub Desktop.
Save nickcaballero/dbf52dea7b549a588e50c3500483d694 to your computer and use it in GitHub Desktop.
Babylist sum of registry items
// Run this in console
[...document.querySelectorAll('.mtm')]
.map(group => [...group.querySelectorAll('.offer-price')]
.map(element => parseFloat(element.textContent.substring(1)))
.reduce((agg, value, i) => (agg + value) / (i ? 2 : 1), 0)) // Take average when product is available on multiple sites
.reduce((sum, value) => sum + value, 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment