this is my code:
const dataset = (element) => {
// TODO: return the element's data attributes in an object
};
I need to do this:
Implement the dataset
function which takes one element
parameter (of type String
) and returns an Object
with the right keys and values:
const burger = `<div class="card" data-id="42" data-price="15" data-category="popular">
<div class="card-category">Popular</div>
<div class="card-description">
<h2>The best burger in town (15€)</h2>
</div>
</div>`;
dataset(burger);
// => { id: 42, price: 15, category: 'popular' }
- It should only return the dataset of the wrapping element regardless of its children
- It should cast the values to the right type (in the example,
42
and15
should benumber
s)
im really new and trying to learn as much as possible i don't have any clue on hoe to do this