diff --git a/part1/src/App.js b/part1/src/App.js index 629ac91..d7a2aa7 100644 --- a/part1/src/App.js +++ b/part1/src/App.js @@ -1,9 +1,16 @@ import { useState } from 'react' -const Stats = ({ positive, neutral, negative }) => { - const total = positive - negative - const votes = positive + neutral + negative - if (votes == 0) { +const StatisticLine = ({ value, text }) => { + return ( + + {text} + {value} + + ) +} + +const Stats = ({ positive, neutral, negative, total, votes }) => { + if (votes === 0) { return ( <>

No Votes Cast Yet

@@ -13,12 +20,12 @@ const Stats = ({ positive, neutral, negative }) => { return ( <>

Results

-

Positive: {positive}

-

Neutral: {neutral}

-

Negative: {negative}

-

All: {votes}

-

Average: {total / votes}

-

Positive: {positive / votes}

+ + + + + + ) } @@ -35,6 +42,8 @@ const App = () => { const [good, setGood] = useState(0) const [neutral, setNeutral] = useState(0) const [bad, setBad] = useState(0) + const total = good - bad + const votes = good + neutral + bad const incPositive = () => { setGood(good + 1) @@ -54,7 +63,7 @@ const App = () => {