Answer the question
In order to leave comments, you need to log in
Problem with populating a 2D array?
We get the text from the input, split it into an array by 1 element, put it into a two-dimensional array
var matrix=[];
var key=prompt('enter key').split(''),
text=input.value.toUpperCase().split(""); //console.log(text);
// console.log(key);
for (var i=0; i<key.length; i++){
matrix[i]=[];
for(var j=0; j<input.length; j++){
matrix[i][j]=text[j];
}
}
Answer the question
In order to leave comments, you need to log in
for (var j = 0; j < text.length; j++) {
matrix[i][j] = text[j];
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question