We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Code Review Feedback
Code Review Feedback
Sort by
recency
|
75 Discussions
|
Please Login in order to post a comment
Before you begin any of these coding tests, you must read the test file to see how they test it. They are not testing functionality sometimes, your failing test might just be an improper test-id that has to be dynamically set.
so many visible bugs in the hackerrank platform i dont even have to point out any
My new component:
This is my FeedBack Component
const FeedbackSystem = () => { // const [Upvote, setUpvote] = React.useState(0) // const [Downvote, setDownvote] = React.useState(0) const [cards, setCards] = React.useState( [ { id: 0, name: "Readability", Upvote: 0, Downvote: 0 }, { id: 1, name: "Performance", Upvote: 0, Downvote: 0 }, { id: 2, name: "Security", Upvote: 0, Downvote: 0 }, { id: 3, name: "Documentation", Upvote: 0, Downvote: 0 }, { id: 4, name: "Testing", Upvote: 0, Downvote: 0 }, ])
function upVote(id) { //setUpvote(prev => prev + 1)
}
function downVote(id) { //setDownvote(prev => prev + 1) setCards(prev => prev.map((card, index) => ( index == id ? { ...card, Downvote: card.Downvote + 1 } : card ))) }
return ( { cards.map((card, index) => (
{card.name}
upVote(index)} downVote={() => downVote(index)} id={index} />); };
export default FeedbackSystem;
This is my Button Component
export default function Button({upVote,downVote,id}) {
return ( <> upvote-btn-{id}} onClick={downVote}> 👎 Downvote ) } Where I made misatke , my test cases are failing
WWhere
import React, {useState} from "react";
const aspects = ["Readability", "Performance", "Security", "Documentation", "Testing"];
const FeedbackSystem = () => { const [feedback, setFeedback] = useState( aspects.map(() => ({ upvotes: 0, downvotes: 0 })) );
const handleUpvote = (index) => { const newFeedback = [...feedback]; newFeedback[index].upvotes ++; setFeedback(newFeedback); };
const handleDownvote = (index) => { const newFeedback = [...feedback]; newFeedback[index].downvotes ++; setFeedback(newFeedback); }; return ( {aspects.map((aspect, index) => (
{aspect}
upvote-btn-{index}} onClick={() => handleDownvote(index)}> 👎 Downvote upvote-btn-${index}}> Upvotes: {feedback[index].upvotes} downvote-count-${index}}> Downvotes: {feedback[index].downvotes} ))} ); };export default FeedbackSystem;