Question: So Im doing the automate the boring stuff course and Im trying to scrape the amazon prices for the automate the boring stuff book, but it is returning an empty string no matter what and as a result an index error occurs at `elems[0].text.strip()` and i don't know what to do.

```py
def getAmazonPrice(productUrl):
    headers = {'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0'} # to make the server think its a web browser and not a bot
    res = requests.get(productUrl, headers=headers)
    res.raise_for_status()

    soup = bs4.BeautifulSoup(res.text, 'html.parser')
    elems = soup.select('#mediaNoAccordion > div.a-row > div.a-column.a-span4.a-text-right.a-span-last')
    return elems[0].text.strip()

price = getAmazonPrice('https://www.amazon.com/Automate-Boring-Stuff-Python-2nd-ebook/dp/B07VSXS4NK/ref=sr_1_1?crid=30NW5VCV06ZMP&dchild=1&keywords=automate+the+boring+stuff+with+python&qid=1586810720&sprefix=automate+the+bo%2Caps%2C288&sr=8-1')
print('The price is ' + price)

```

Answer: 
You could use `Array.reduce`:

```
[...].reduce((acc, next) => {
  // Check if an item with the given date exists
  const existingItem = acc.find(item => item.date === next.date);
  // If not, add the new one to the array
  if (!existingItem) {
    return [...acc, next];
  }
  // If there's one already, mutate the value property and return everything
  existingItem.value += next.value;
  return acc;
}, []);

```
Will this work for you?

```js
let myArr = [{
    date: "07-04-2020",
    value: 10
  },
  {
    date: "10-04-2020",
    value: 20
  },
  {
    date: "07-04-2020",
    value: 30
  },
  {
    date: "14-04-2020",
    value: 60
  },
]

function sum(arr) {
  let result = [];
  let temp = {};

  arr.forEach((row) => {
    temp[row.date] = temp[row.date] ? temp[row.date] + row.value : row.value;
  });

  Object.entries(temp).forEach((dateValue) => {
    result.push({
      date: dateValue[0],
      value: dateValue[1]
    });
  });

  return result;
}
console.log(sum(myArr));
```