Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

156
Vistas
i want Give values for a nested object from array js

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]}
}

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda