Skip to content

Commit

Permalink
fixed warnings in game3.js
Browse files Browse the repository at this point in the history
  • Loading branch information
alegarman2002 committed Apr 10, 2024
1 parent 5ef7220 commit 0871440
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions webapp/src/components/game/Game3.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const apiEndpoint = process.env.REACT_APP_API_ENDPOINT|| 'http://localhost:8000'
var isCorrect = false
var questions = [];
var points = 0;
var numErrors = 3;

const Quiz = () => {

Expand All @@ -24,13 +25,12 @@ const Quiz = () => {
var id = useLocation().state.gameId;

const [remTime, setRemTime] = useState(0);
const [numErrors, setNumErrors] = useState(3);


useEffect(() => {
const time = setInterval(() => {
setRemTime((progress) => {
if(progress == 100){
if(progress === 100){
newQuestion();
return 0;
}
Expand Down Expand Up @@ -104,8 +104,10 @@ const Quiz = () => {
try {
var username = localStorage.getItem("username")
const response = await axios.post(`${apiEndpoint}/storeGame`, { id, username, points, questions});
console.log(response)
questions = []
points = 0
numErrors = 3
} catch (error) {
console.error(error)
}
Expand Down Expand Up @@ -136,7 +138,7 @@ const Quiz = () => {

await esperar(2000); // Espera 2000 milisegundos (2 segundos)
botonCorrecta.style.backgroundColor = previousBackgroundColor
if (allQuestions.length-1 != currentQuestionIndex) {
if (allQuestions.length-1 !== currentQuestionIndex) {
currentQuestionIndex = (currentQuestionIndex + 1);
}
isCorrect = (false)
Expand All @@ -158,8 +160,8 @@ const Quiz = () => {
if (!isCorrect) {
botonIncorrecta.style.backgroundColor = 'red'

setNumErrors(numErrors--);
if(numErrors == 0){
numErrors -= 1
if(numErrors === 0){
haveFailedQuestion = true;
}
} else {
Expand All @@ -182,7 +184,7 @@ const Quiz = () => {
await esperar(2000); // Espera 2000 milisegundos (2 segundos)
botonIncorrecta.style.backgroundColor = previousBackgroundColor
botonCorrecta.style.backgroundColor = previousBackgroundColor
if (allQuestions.length-1 != currentQuestionIndex) {
if (allQuestions.length-1 !== currentQuestionIndex) {
currentQuestionIndex = (currentQuestionIndex + 1);
}
isCorrect = (false)
Expand Down

0 comments on commit 0871440

Please sign in to comment.