79687865

Date: 2025-07-02 17:44:48
Score: 0.5
Natty:
Report link

What, no love for Object.entries()? This seems to be exactly what you're looking for...

function getDataset(e) {
    return new Map(Object.entries(e.dataset));
}

function getDatasetValuesArray(e) {
    return Object.entries(e.dataset).map(([, value]) => value);
}


for ( let e of document.querySelectorAll('p') ) {
    let datasetValuesArray = getDatasetValuesArray(e);
    e.textContent = datasetValuesArray.join(", ");
}
<p data-one="foo">...</p>
<p data-one="bar" data-two="baz">...</p>

Reasons:
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Starts with a question (0.5): What
Posted by: JamesTheAwesomeDude