Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

337
Views
Estoy tratando de hacer un clon de wordle, pero por alguna razón mi mensaje de felicitaciones no se muestra cuando el usuario dice la palabra correcta. ¿Cómo puedo arreglarlo?
let body = document.querySelector("body") let container = document.querySelector("#container") let enter = document.querySelector("#enter") let restart = document.querySelector("#restart") let inputArr = [] for (let rowCount = 0; rowCount < 6; rowCount++) { let row = [] inputArr.push(row) for (let column = 0; column < 5; column++) { let space = document.createElement("input") space.classList.add("square") container.appendChild(space) row.push(space) } } function wordle() { let wordSet = ["panic", "dupes", "crate", "great", "soare", "avoid", "knobs", "venom"] let correct = [] let enteredLetters = [] let num = Math.floor(Math.random()*wordSet.length) let word = wordSet[num] console.log(word) let enterClicks = -1 enter.addEventListener("click", () => { enterClicks++ for (let rowVal = 0; rowVal < 6; rowVal++) { for (let col = 0; col<5; col++) { let square = inputArr[rowVal][col] let current = square.value if (current == word[col]) { square.style.backgroundColor = "green" correct.push(current) } if (current !== word[col] && word.indexOf(current) !== -1) { square.style.backgroundColor = "yellow" } if (current == "") { current.disabled = false for (let z = 0; z < 5; z++) { inputArr[rowVal][z].style.backgroundColor = "white" } } if (current !== word[col] && word.indexOf(current) == -1) { square.style.backgroundColor = "darkgray" } } } for (let c = 0; c < 6; c++) { inputArr[enterClicks][c].disabled = true enteredLetters.push(inputArr[enterClicks][c].value) } let foundLetters = [] for (let w = 0; w < 5; w++) { if (correct.indexOf(word[w]) !== -1) { foundLetters.push(word[w]) } } if (foundLetters.length == 5) { window.alert("Congratulations! You Beat Wordle 2.0! Click the 'PLAY AGAIN' button to start a new round.") } }) } wordle() restart.onclick = () => { location.reload() }

Por cierto, la matriz de letras encontradas básicamente almacena los caracteres que coinciden tanto en la palabra como en la matriz correcta. Todo lo demás parece estar funcionando perfectamente bien, pero es solo el último fragmento de código, desde la declaración de foundLetters hasta el final, que no parece funcionar como debería.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!