Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

122
Visualizações
How do I read out an 2d array in JavaScript with values and print it in a label with a button

My plan is that you put in a value like [1][2] which should be the car in the middle. Then start with a button and output the color of the car.

I have tried this but it doesn't work:

function printcars() {

  let garage = [
    ["hellrot", " blau", " türkis"],
    [" braun", " minzgrün", " schwarz"],
    [" silber", " pink", " dunkelrot"]
  ];

  var k = "The respective values are :";

  function Geeks() {
    var input = document.getElementsByName('garage[]');

    for (let i = 0; i < garage.length; i++) {
      for (let j = 0; j < garage[i].length; j++) {
        var a = input[i];
        var b = input[j];
        k = k + "garage[" + i + "].value= "
          + a.value + " ";
      }

      document.getElementById("par").innerHTML = k;
      document.getElementById("po").innerHTML = "Output";
    }
  }
}

enter image description here

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda