Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

140
Vistas
For a wordle clone on code.org, how can I make it so that words that are in the right spot/in the word turn yellow?

So I am making a wordle clone in code.org using the dataset, yet I am facing two issues.

The first issue is that when I console.log the correct answer, sometimes it says "null" and other times it works without issue.

The second problem is I don't know how to make the words yellow if they are out of order or in the word. My code is down below.

//Getting Wordle Answer 
var answers = getColumn("Wordle", "validWordleAnswer");
var index = (randomNumber(0, answers.length));
console.log(answers[index]);
var letters =  ["letter1", "letter2", "letter3", "letter4", "letter5"];


    //Checking Words
    onEvent("wordbutton", "click", function( ) {
      var guess = getProperty("wordInput", "text");
      for (var i = 0; i < 5; i++) {
       
    
         if (guess == answers[index]) {
              setProperty(letters[i], "background-color", "green");
            } else if ((answers[index].includes(guess))) {
              setProperty(letters[i], "background-color", "yellow");
            } else {
              setProperty(letters[i], "background-color", "red");
            }
        setProperty(letters[i], "text", guess[i]);
      }
    });

Specifically the else if statement, and the first four lines of code that are my variables

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I can answer the first one. The correct answer Wordle data set on code.org contains a null values past 2038, so instead my code for picking a random correct answer looks like this:

var correctAnswerList = getColumn("Wordle", "validWordleAnswer");
function pickWord() {
 randomWord = randomNumber(0,2038 );
 correctAnswer = correctAnswerList[randomWord];

If you figure out how to get letters to turn yellow please share!

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda