diff --git a/part1/1.6-1.11-unicafe/src/App.js b/part1/1.6-1.11-unicafe/src/App.js index 58de94e..0a1dc1c 100644 --- a/part1/1.6-1.11-unicafe/src/App.js +++ b/part1/1.6-1.11-unicafe/src/App.js @@ -6,23 +6,36 @@ const App = () => { const [neutral, setNeutral] = useState(0) const [bad, setBad] = useState(0) - const all = good + bad + neutral - const avg = (all !== 0) ? (good - bad) / all : 0 - const positive = (all !== 0) ? good/all*100 : "NA" + + const Statistics = (props) => { + const [good, neutral, bad] = props.data + const all = good + bad + neutral + const avg = (all !== 0) ? (good - bad) / all : 0 + const positive = (all !== 0) ? good/all*100 : "NA" + + return ( +
+

Statistic

+

Good: {good}

+

Neutral: {neutral}

+

Bad: {bad}

+

All: {all}

+

Average: {avg}

+

Positive: {positive} %

+
+ ) + } return (

Give feedback

+ -

Statistic

-

Good: {good}

-

Neutral: {neutral}

-

Bad: {bad}

-

All: {all}

-

Average: {avg}

-

Positive: {positive} %

+ + +
) }