From d26d66763cfc7f6e0eecfe2d7bc5796bd1645e7c Mon Sep 17 00:00:00 2001 From: Thuan Bui Date: Thu, 26 Aug 2021 20:11:28 +0700 Subject: [PATCH] Completed 1.7 (unicafe step 2) --- part1/1.6-1.11-unicafe/src/App.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/part1/1.6-1.11-unicafe/src/App.js b/part1/1.6-1.11-unicafe/src/App.js index cd55853..58de94e 100644 --- a/part1/1.6-1.11-unicafe/src/App.js +++ b/part1/1.6-1.11-unicafe/src/App.js @@ -6,6 +6,10 @@ 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" + return (

Give feedback

@@ -16,6 +20,9 @@ const App = () => {

Good: {good}

Neutral: {neutral}

Bad: {bad}

+

All: {all}

+

Average: {avg}

+

Positive: {positive} %

) }