-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
09ead99
commit c337c3b
Showing
3 changed files
with
30 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,33 @@ | ||
import React from 'react'; | ||
import React, { useState } from "react"; | ||
|
||
const Quiz = ({ quiz }) => { | ||
|
||
const { options, question,correctAnswer } = quiz; | ||
console.log(quiz); | ||
const[correct, setCorrect] = useState(false); | ||
|
||
const handleQuiz = (answer, correctAns) => { | ||
if(answer == correctAns){ | ||
alert("Your answer is true") | ||
} | ||
else{ | ||
alert("your answer is false") | ||
} | ||
|
||
const Quiz = ({quiz}) => { | ||
// console.log(quiz); | ||
// const{question,options} = quiz; | ||
// const allOption = quiz.options; | ||
// // const allOption = quiz[0]; | ||
// // const {option} = allOption; | ||
// console.log(allOption); | ||
const{options, question} = quiz; | ||
} | ||
|
||
|
||
return ( | ||
<div> | ||
|
||
<div> | ||
{ | ||
<h1>Quiz: {question}</h1> | ||
} | ||
{ | ||
options.map(option => <p>{option}</p>) | ||
} | ||
</div> | ||
|
||
</div> | ||
); | ||
return ( | ||
<div> | ||
<div> | ||
{<h1>Quiz: {question}</h1>} | ||
{options.map((option, i) => ( | ||
<div className="py-2 bg-gray-400 my-4 "> | ||
{i}.<button onClick={()=>handleQuiz(option, correctAnswer)}>{option}</button> | ||
</div> | ||
))} | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Quiz; | ||
export default Quiz; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters