I need to write a function that takes in 2 arguments, the first argument is a list of <li>
elements and the second argument is an object. The object is list of products and their prices. All the <li>
elements will have text containing a name of a product.The function should check the price of each product mentioned, calculate and return the total price.
Example:
<ul>
<li>oreos<li/>
<li>milk<li/>
<ul/>
let products = {
oreos: 20,
milk: 17,
bread: 12,
doritos: 10
}
I have tried using a for in/of loop to go through the products object and match it to the <li>
using .innerText
but am unsure of how to go about doing it.
Please help out