"use strict";

const fruits = [
    { name: "apple", count: 5, price: 70 },
    { name: "orange", count: 10, price: 90 },
    { name: "pineapple", count: 15, price: 110 },
    { name: "watermelon", count: 20, price: 130 },
    { name: "cherry", count: 25, price: 150 },
    { name: "pear", count: 30, price: 170 },
    { name: "peach", count: 35, price: 190 },
];

// Сюда бы reduce...
const bill1 = {
    bill: fruits,
    result: (() => {
        let sum = 0;
        for (let i = 0; i < fruits.length; i++) {
            sum += fruits[i].count*fruits[i].price;
        }
        return sum;
    })()
}
console.log(JSON.stringify(bill1));

// Подсчёт суммы forEach'ем
const bill2 = {
    bill: fruits,
    result: (() => {
        let sum = 0;
        fruits.forEach(fruitO => sum += fruitO.count*fruitO.price);
        return sum;
    })()
}
console.log(JSON.stringify(bill2));

// Выведем ещё и дату
console.log(`Сегодня ${new Date().toLocaleDateString("ru-RU", {weekday: "long", year: "numeric", month: "2-digit", day: "2-digit"})}`);
