Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

152
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda