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

139
Vistas
Why reply variable is giving index number of greetReply array? I want the value from that array

var submit = document.getElementById("submit");
var value = document.getElementById("value");

var greeting = ['hi', 'hello', 'Hlw', 'hello jii', 'hey', 'helo', 'hi there', 'hey']
var greetReply = ['hlw', 'kisu na', 'gaan shuni'];


submit.addEventListener('click', () => {
    const reply = Math.floor(Math.random() * greetReply.length); // random reply!

    for (let i = 0; i < greeting.length; i++) {
        if(value.value === greeting[i]){
            console.log(reply)
        }
    }
})

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

0

you have to access the value of the array by the index number, try to modify this line:

console.log(greetReply[reply])

about 4 years ago · Juan Pablo Isaza Denunciar

0

reply is a random index from greetReply to get value of that index use it this way greetReply[reply]

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