Ok, thank you for your input.. it means that I'll just make a function to place into an array with 4 arguments.. col,row,arr&data
//important function
function place2d(row,col,arr,data){
//row col logic works like arr[row][col]
arr[row]=arr[row]||[]
arr[row][col]=data
}
var array2dArray=[]
//this loop would take the data array and place the entire index in the desired destination
data.forEach(a=>{
var [row,col]=a[0].split(',')
place2d(row,col,array2dArray,a) //the data to put into each part of the 2d array would an array itself(like data[0])
})
console.log(array2dArray)
//but I might just wanna put the text in the 2d array
var text2dArray=[]
data.forEach(a=>{
var [row,col]=a[0].split(',')
place2d(row,col,text2dArray,a[1]) //the data to be put in each part of the 2d array would be the a text variable(like data[0][1] is "hello")
})
console.log(text2dArray)
<script>
//sry it just takes space in the js part that's unnessecary
window.data = [
[
"0,0,5",
"hello"
],
[
"0,1,10",
"js is fun!"
],
[
"0,2,0",
""
]
]
</script>
With this function, you can take an empty array, place row 10 col 4 in empty array putting any data like 'xD' and it will work out eg: try place2d(10,4,emptyArrName,"xD") and it works.. just one thing to note..
IT ONLY APPLIES array structures to WHERE IT NEEDS TO.. doing things like the example above would leave a lot of undefined slots.. wild example below
//now for a wild example to show that the function works
window.data2=[
["text for [10][0]","0/10"],
["text for [2][5]","5/2"]
]
//don't forget the placer function :D
function place2d(row,col,arr,data){
//row col logic works like arr[row][col]
arr[row]=arr[row]||[]
arr[row][col]=data
}
//at the end of the day, all I'm changing is the information I make out of the array in the forEach loops in order to simply place in the function
var finalArray=[]
place2d(3,4,finalArray,"randomDataThatCouldBe_ANYTHING_notJustText")
data2.forEach(a=>{
var [col,row]=a[1].split('/')
place2d(row,col,finalArray,a[0])
})
console.log(finalArray)
"0,0,5"and place the 5 char text in2dArray[0][0]?2dArray[0][0]should have the valuehellodatawould always be in that format? example..normalArr[2]pointing to2dArr[0][2]? or is it just each array pointing to any 2d place?[2][0]or[1][2]and other positions as well. @TheBombSquad