Untitled

 avatar
unknown
plain_text
12 days ago
668 B
3
Indexable
function generateItems(count) {
  const names = ["John", "Jane", "Ivan", "Mario", "Hans", "Chen", "Emily", "Liam", "Sophia", "Oliver"];
  const countries = ["USA", "Germany", "China", "Italy", "Ukraine", "France", "Canada", "Spain", "Japan", "Brazil"];

  const items = [];

  for (let i = 0; i < count; i++) {
    const name = `${names[Math.floor(Math.random() * names.length)]} ${String.fromCharCode(65 + Math.floor(Math.random() * 26))}.`;
    const country = countries[Math.floor(Math.random() * countries.length)];

    items.push({
      id: i + 1,
      name,
      country
    });
  }

  return items;
}

const items = generateItems(3000);
console.log(items);
Editor is loading...
Leave a Comment