mirror of
https://github.com/10h30/fullstackopen.git
synced 2026-06-05 15:08:33 +09:00
Completed 1.9 (unicafe step 4)
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user