Last active
April 3, 2019 20:33
-
-
Save Pustur/cdeffc222450cb4c814b6831cfc2d8a5 to your computer and use it in GitHub Desktop.
JavaScript – Return an object of all the html tag names and the number of times they appear in the document
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
const uniqueDomElements = () => | |
Array.from(document.querySelectorAll('*')).reduce( | |
(obj, { tagName }) => { | |
obj[tagName] = obj[tagName] + 1 || 1; | |
obj._total += 1; | |
return obj; | |
}, | |
{ _total: 0 } | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment