I am currently working on a grid that resembles a table, but is custom-created with divs and spans. My goal is to populate each cell with values from multiple arrays, however, I am encountering some difficulties in making it work properly.
function generate(count, values) {
return Array.apply(null, { length: count }).map(function () {
var r = [],
array = values.slice();
while (array.length) {
r.push(array.splice(Math.floor(Math.random() * array.length), 1)[0]);
}
return r;
});
};
var myStringArray = generate(7, [1, 2, 3, 4, 5, 6, 7]);
var arrayLength = myStringArray.length;
for (var i = 0; i < arrayLength; i++) {
console.log(myStringArray[i]);
}
Despite my efforts, I have not been able to successfully add each array to its corresponding row.
Array.from(document.getElementsByClassName('cell')).forEach(function(e, j) {
e.textContent = myStringArray[i];
});