I'm trying to replace the "hi" value with serial values from the array But that didn't work
I'm trying to replace the "hi" value with serial values from the array But that didn't work
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"}
}
}
i want Give values for a nested object from array js As in the example below
"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]}
}