Completed 1.9 (unicafe step 4)

This commit is contained in:
2021-08-26 20:26:57 +07:00
parent 59be6fbdaa
commit b510a037b2
+13 -7
View File
@@ -12,16 +12,22 @@ const App = () => {
const all = good + bad + neutral
const avg = (all !== 0) ? (good - bad) / all : 0
const positive = (all !== 0) ? good/all*100 : "NA"
return (
<div>
<h1>Statistic</h1>
<p>Good: {good}</p>
<p>Neutral: {neutral}</p>
<p>Bad: {bad}</p>
<p>All: {all}</p>
<p>Average: {avg} </p>
<p>Positive: {positive} %</p>
{all > 0 &&
<div>
<p>Good: {good}</p>
<p>Neutral: {neutral}</p>
<p>Bad: {bad}</p>
<p>All: {all}</p>
<p>Average: {avg} </p>
<p>Positive: {positive} %</p>
</div>
}
{all === 0 && "No feedback given"}
</div>
)
}
@@ -29,7 +35,7 @@ const App = () => {
return (
<div>
<h1>Give feedback</h1>
<button onClick={() => setGood(good + 1)}>good</button>
<button onClick={() => setNeutral(neutral + 1)}>neutral</button>
<button onClick={() => setBad(bad + 1)}>bad</button>