Skip to content

Instantly share code, notes, and snippets.

@lubien
Last active February 1, 2018 20:22
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 lubien/93279c4c6bb97d4e2789838b3e320ca8 to your computer and use it in GitHub Desktop.
Save lubien/93279c4c6bb97d4e2789838b3e320ca8 to your computer and use it in GitHub Desktop.
FreeCodeCamp count. Count how many stuff you'd have to do on FreeCodeCamp (wrote on devtools, inb4: clean code)
JSON.stringify(Array.from(document.querySelectorAll('#accordion > *')).map((node, i, items) => {
if (node.nodeName !== 'H2') return false
const next = items[i + 1]
return {
title: node.querySelector('a').innerText.trim(),
items: Array.from(next.querySelectorAll('#nested > *')).map((node, i, items) => {
if (node.nodeName !== 'H3') return false
const next = items[i + 1]
return {
title: node.querySelector('a').innerText.trim(),
time: node.querySelector('.challengeBlockTime').innerText.trim().slice(1, -1),
items: next.querySelectorAll('p').length
}
}).filter(x => x)
}
}).filter(x => x)
, null, ' ')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment