Commit 5b4f23dc authored by baesangjune's avatar baesangjune
Browse files

.

parent c3ab49b5
...@@ -5,6 +5,7 @@ import React from 'react' ...@@ -5,6 +5,7 @@ import React from 'react'
// import { Link } from 'react-router-dom'; // import { Link } from 'react-router-dom';
function End() { function End() {
let result = ''
let scores = [] let scores = []
let score = 0 let score = 0
const answers = JSON.parse(localStorage.getItem('Answers')) const answers = JSON.parse(localStorage.getItem('Answers'))
...@@ -16,11 +17,17 @@ function End() { ...@@ -16,11 +17,17 @@ function End() {
scores[i] = 1 scores[i] = 1
} }
else if (answers[i] === 0) {
scores[i] = -1
}
else { else {
scores[i] = 0 scores[i] = 0
} }
score += scores[i] score += scores[i]
if (score <0){
score =0
}
} }
return ( return (
...@@ -36,8 +43,18 @@ function End() { ...@@ -36,8 +43,18 @@ function End() {
</thead> </thead>
<tbody> <tbody>
{scores.map((score, index) => { {scores.map((score, index) => {
if (score === -1) {
result = <tr><td>Quiz {index + 1}</td> <td> 정답이 입력되지 않았습니다. </td></tr>
}
else if (score === 1) {
result = <tr><td>Quiz {index + 1}</td> <td> O </td></tr>
}
else {
result = <tr><td>Quiz {index + 1}</td> <td> X</td></tr>
}
return (score === 1) ? <tr><td>Quiz {index + 1}</td> <td> O </td></tr> : <tr><td>Quiz {index + 1}</td> <td> X</td></tr> return result
})} })}
<tr> <tr>
<td>총점</td> <td>총점</td>
...@@ -48,7 +65,7 @@ function End() { ...@@ -48,7 +65,7 @@ function End() {
</div> </div>
</> </>
......
...@@ -6,9 +6,9 @@ import logo from './img_question.png' ...@@ -6,9 +6,9 @@ import logo from './img_question.png'
const QnA = [ const QnA = [
{ Q: "6 X 4 = ?", Choose: [6, 12, 18, 24], A: "4", N: 1 }, { Q: "6 X 4 = ?", Choose: [6, 12, 18, 24], N: 1 },
{ Q: "3 + 3 = ?", Choose: [2, 4, 6, 8], A: "3", N: 2 }, { Q: "3 + 3 = ?", Choose: [2, 4, 6, 8], N: 2 },
{ Q: "3 - 1 = ?", Choose: [1, 2, 3, 4], A: "2", N: 3 } { Q: "3 - 1 = ?", Choose: [1, 2, 3, 4], N: 3 }
] ]
let Answers = [0,0,0] let Answers = [0,0,0]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment