Hey there 👋. In this article, you will learn the basic principles of the sort() array method in JavaScript, its use cases, along with some practical tasks at the end of the lesson. Prerequisites Before you continue with this tutorial, you should cer...

Markdown supported · ⌘↵ to post
Nicely written UBB, I don't know if I'm correct, in your formula you wrote likes + comments, but I couldn't sort but likes and comments without breaking one.
So I only checked for likes...
const descendingLikes = (array) => { return array.sort((a, b) => { return a.likes - b.likes }); }; const ascendingLikes = (array) => { return array.sort((a, b) => { return b.likes - a.likes; }); }; console.log(descendingLikes(blogPosts)) console.log(ascendingLikes(blogPosts))