I have this array/object:
const template = {0: [0, 1, 2, 3, 4, 5], 1: [0, 1, 2, 3, 4, 6]}
// I have the above but happy to convert the below if it helps:
//const templateArr = [[0, 1, 2, 3, 4, 5],[0, 1, 2, 3, 4, 6]]
Then I have an array that I want to map into that sequence:
const myArray = ["Q","W","A","S","Z","X,"E","R","D"] // for example
My intention it to have following result:
let myResult = [["Q", "W", "A", "S", "Z", "X"],["Q", "W", "A", "S", "Z", "E"]]
So all the values of myArray
are in the positions set by template
.
I'm not sure if I should use .map()
or something else... Can someone point me in the right direction??
Thank you so much!