JSFiddle - React, Tailwind, and code Playground

by Sergey Linnick

HTML

<ul id="list"></ul>

JavaScript

const countUsersTodos = async () => {
  const response = await fetch('https://jsonplaceholder.typicode.com/todos');
  const json = await response.json();
  const result = {};

  for (const {
      userId,
      completed
    } of json) {

    let existingItem = result[userId];
    if (!existingItem) {
      existingItem = {
        completedTasks: 0,
        incompletedTasks: 0,
      };
      result[userId] = existingItem;
    }

    if (completed) {
      existingItem.completedTasks++;
    } else {
      existingItem.incompletedTasks++;
    }
  }

  let listContent = []
  for (const [userId, item] of Object.entries(result)) {
    listContent.push(`<li>Пользователь userID=${userId} имеет ${item.completedTasks} завершенных и ${item.incompletedTasks} не завершенных заданий.</li>`);

  }
  const listContentToString = listContent.join('');
  const htmllist = document.getElementById('list');
  htmllist.innerHTML = listContentToString;
};

countUsersTodos();