4

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

muhammad
  • 245
  • 1
  • 13
  • 5
    can you add the `for in/of loop` you tried ? – Taki Oct 08 '19 at 13:48
  • Rather than going through the `products` object you should go through your list of `
  • `s, since looking each text in the products object should be faster
  • – Ayrton Oct 08 '19 at 13:50