კომენტარის სახით ახსენით თითოეული ხაზი რას აკეთებს.
შემდეგ შეასრულეთ მოცემული ამოცანები:
- count average price
- count average words per description
- count average characters per description
- count maximum words in descriptions
- count minimum price in descriptions
(მოგიწევთ გაარკვიოთ რა არის object-ი)
const PRODUCT_COUNT = 50;
const products = [];
// Generate Products
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min
}
function getRandomString(length) {
let text = '';
for (let i = 0; i < length; i++) {
if (getRandomInt(0, 100) > 10)
text += String.fromCharCode(getRandomInt(97, 122));
else
text += ' ';
}
return text;
}
for (let i = 0; i < PRODUCT_COUNT; i++)
products.push({
title: getRandomString(getRandomInt(30, 60)),
price: getRandomInt(500, 5000),
description: getRandomString(getRandomInt(300, 1000))
})