'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";
}
}
}

Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
