Commit 1b072faf authored by baesangjune's avatar baesangjune
Browse files

end 수정

parent d809327d
...@@ -5,21 +5,22 @@ import tr from './img_end.jpg'; ...@@ -5,21 +5,22 @@ import tr from './img_end.jpg';
// import { Link } from 'react-router-dom'; // import { Link } from 'react-router-dom';
function End() { function End() {
let Scores = [] let scores = []
let Score = 0 let score = 0
JSON.parse(localStorage.getItem('Answers')) const answers = JSON.parse(localStorage.getItem('Answers'))
for (let i = 0; i < 3; i++) { const solutions = JSON.parse(localStorage.getItem('Solutions'))
for (let i = 0; i < answers.length ; i++) {
if (JSON.parse(localStorage.getItem('Answers'))[i] === JSON.parse(localStorage.getItem('Solutions'))[i]) { if (answers[i] === solutions[i]) {
Scores[i] = 1 scores[i] = 1
} }
else { else {
Scores[i] = 0 scores[i] = 0
} }
Score += Scores[i] score += scores[i]
} }
return ( return (
...@@ -30,17 +31,17 @@ function End() { ...@@ -30,17 +31,17 @@ function End() {
<div className='card-body'> <div className='card-body'>
<h3 className='card-title'>이름 : {localStorage.getItem('name')}</h3> <h3 className='card-title'>이름 : {localStorage.getItem('name')}</h3>
{Scores.map(score => { {scores.map((score, index) => {
for (let i = 0; i < 3; i++) {
if (score === 1) { if (score === 1) {
return <p className='card-text'>Quiz {(i + 1)} : 'O' </p> return <p className='card-text'>Quiz {index+1} : 'O' </p>
} }
else { return <p className='card-text'>Quiz {(i + 1)} : 'X' </p> } else { return <p className='card-text'>Quiz {index+1} : 'X' </p> }
}
})} })}
<p className='card-text'>Total Score : {Score}</p> <p className='card-text'>Total Score : {score}</p>
</div> </div>
<div style={{ marginTop: '100px' }} className="Box text-center"> <div style={{ marginTop: '100px' }} className="Box text-center">
<img src={tr} alt="수고" /> <img src={tr} alt="수고" />
......
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