0
Hello Javascript masters, I am studying multidimensional vectors, I have the following code, the file . js:
var funcionarios = [[]], indiceLinha, indiceColuna;
for the index.html file:
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="utf-8" />
<title>Aprendendo Algoritmos com JavaScript</title>
</head>
<body>
<script src="scripts/aplicativo_021.js"></script>
<script>
for (indiceLinha = 0; indiceLinha < 2; indiceLinha++)
{
funcionarios[indiceLinha] = (prompt("Digite o Nome do Funcionário:"));
for (indiceColuna = 0; indiceColuna < 2; indiceColuna++)
{
funcionarios[indiceColuna] = (prompt("Digite o Cargo do Funcionário:"));
funcionarios[indiceLinha] = (prompt("Digite o Nome do Funcionário:"));
}
}
for (indiceLinha = 0; indiceLinha < 2; indiceLinha++)
{
for (indiceColuna = 0; indiceColuna < 2; indiceColuna++)
{
document.write("Nome do Funcionário " + funcionarios[indiceLinha] + "\n");
document.write("<br>");
document.write("Cargo do Funcionário " + funcionarios[indiceColuna] + "\n");
document.write("<br>");
}
}
</script>
</body>
</html>
I can’t see where I’m going wrong. Anyone who can help, I stand by.
I’ll answer in the same way that I answered in the comments of a question about 40 minutes ago, search for matrices with javascript, and then use for example, the model
matriz[i][j] = valor
. If you still have doubts, they will be better prepared. anything, edit the question– Murilo Melo
Dear Murilo, thank you very much for your reply, it did not help much, because when I go to the forum, it is because I already researched on the subject and I could not find what I wanted. Yet very grateful for your precious time.
– Montesuma
Possible duplicate of fill array to generate json javascript
– Montesuma