• + 0 comments

    This is my code but test cases failed!

    import React, { useState } from "react";

    const intialFeedback = [{ name: "Readability", upvote: 0, downvote: 0 }, { name: "Performance", upvote: 0, downvote: 0 }, { name: "Security", upvote: 0, downvote: 0 }, { name: "Documentation", upvote: 0, downvote: 0 }, { name: "Testing", upvote: 0, downvote: 0 }];

    const FeedbackSystem = () => { const [feedback, setFeedback] = useState(intialFeedback)

    const handleUpVote = (name) => { setFeedback(pre => { return pre.map(item => { if(item.name === name){ item.upvote+=1; }

        return item;
      }); 
    })
    

    }

    const handleDownVote = (name) => { setFeedback(pre => { return pre.map(item => { if(item.name === name){ item.downvote+=1; }

        return item;
      }); 
    })
    

    }

    return ( {feedback.map((item, index) => {handleDownVote(item.name)}} handleUpVote={()=>{handleUpVote(item.name)}} index={index} {...item} /> )} ); };

    export default FeedbackSystem;

    function FeedbackCard({ name,upvote, downvote, handleDownVote, handleUpVote, index }) { return (

    {name}

    upvote-btn-Extra close brace or missing open brace{index}} onClick={handleDownVote}> 👎 Downvote upvote-count-${index}}> Upvotes: {upvote}

    downvote-count-${index}}> Downvotes: {downvote}

    ) }