Estoy tratando de reemplazar el valor "hola" con valores en serie de la matriz, pero eso no funcionó
Estoy tratando de reemplazar el valor "hola" con valores en serie de la matriz, pero eso no funcionó
let final = [ [ 'q0', 'S0' ], [ 'q1', 'S0' ], [ 'q0', 'S1' ], [ 'q2', 'S0' ] ] let array = m [ [ 'q1', 'S0' ], [ 'q0', 'S1' ], [ 'q1', 'S0' ], [ 'q2', 'S1' ], [ 'q1', 'S1' ], [ 'q0', 'S0' ], [ 'q1', 'S1' ], [ 'q0', 'S0' ] ] I'm trying to replace the "hi" value with serial values from the array But that didn't work var target1 = {}; arr.forEach((key1) => target1[key1] ="hi" ) var target = {}; final.forEach((key) => target[key] = target1); var dict = { "states" : final, "inputAlphabet" :["0","1"], "startState" : final[0], "EndStates" : [ 'q2', 'S0' ], target }; ``` { "states": [["q0","S0"],["q1","S0"],["q0","S1"],["q2","S1"], ["q1","S1"],["q2","S0"] ], "inputAlphabet": ["0","1"], "startState":["q0","S0"], "EndStates":["q2","S0"], "target":{ "q0,S0":{"0":"hi","1":"hi"}, "q1,S0":{"0":"hi","1":"hi"}, "q0,S1":{"0":"hi","1":"hi"}, "q2,S0":{"0":"hi","1":"hi"} } }quiero Dar valores para un objeto anidado de la matriz js Como en el ejemplo a continuación
"target":{ "q0,S0":{"0":array[0],"1":array[1]}, "q1,S0":{"0":arary[2],"1":array[3]}, "q0,S1":{"0":array[4],"1":array[5]}, "q2,S0":{"0":array[6],"1":array[7]} }