• + 0 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;