Map en Action
Comment transformer :
[['eux', ' ', ' ' ],['A', 'B', 'C' ],['eux', ' ', ' ']]
en
[["eux", "A", "eux"],[" ", "B", " "],[" ", "C", " "]]
Aide
const t=[
['eux', ' ', ' ' ],[ 'A', 'B', 'C' ],[ 'eux', ' ', ' ' ]
]
function drawLine(t, lineNo) {
return t.map(function (block) {
return block[lineNo];
});
}
let a= t[0].map(function (_, lineNo) {
return drawLine(t, lineNo);
});
console.log(a);
["eux", "A", "eux"],[" ", "B", " "],[" ", "C", " "]
https://es6console.com/joeu5t8d/