Who's written the most

by Jason Green

HTML

<div id="out">

</div>

JavaScript

log('Starting');

// We can fetch posts by user like this
fetch('https://jsonplaceholder.typicode.com/posts?userId=1')
.then((res) => res.json())
.then((data) => log('Number of posts: ' + data.length));

// So let's write a function that takes an array of ids and returns a promise that will return the id of the user who has written the most content.
function userWithMostContent(userIds) {
	
}

// To be used like this

//userWithMostContent([1, 4, 5]).then(id => log(`User ${id} has written the most`));













function log(str) {
	var prev = document.getElementById('out').innerHTML;
  document.getElementById('out').innerHTML = prev + str + '<br>';
}