You are viewing a single comment's thread. Return to all comments →
all test cases are failing for this import "h8k-components"; import React, {useState} from "react"; import Articles from "./components/Articles";
import "./App.css";
function App({ articles }) { const [ articlesData, setArticles] = useState([...articles].sort((a, b)=> b.upvotes - a.upvotes)); const handleMostUpvoted = () => { // Logic for most upvoted articles const sortedList = [...articlesData].sort((a, b)=> b.upvotes - a.upvotes); setArticles(sortedList); };
const handleMostRecent = () => { const sortedList = [...articlesData].sort((a, b)=> new Date(b.date) - new Date(a.date)); setArticles(sortedList); }; return ( <> Sort By Most Upvoted Most Recent ); }
export default App;
Seems like cookies are disabled on this browser, please enable them to open this website
Article Sorting
You are viewing a single comment's thread. Return to all comments →
all test cases are failing for this import "h8k-components"; import React, {useState} from "react"; import Articles from "./components/Articles";
import "./App.css";
function App({ articles }) { const [ articlesData, setArticles] = useState([...articles].sort((a, b)=> b.upvotes - a.upvotes)); const handleMostUpvoted = () => { // Logic for most upvoted articles const sortedList = [...articlesData].sort((a, b)=> b.upvotes - a.upvotes); setArticles(sortedList); };
const handleMostRecent = () => { const sortedList = [...articlesData].sort((a, b)=> new Date(b.date) - new Date(a.date)); setArticles(sortedList); }; return ( <> Sort By Most Upvoted Most Recent ); }
export default App;