Modify javascript forEach result with value from another Array












2














I want to modify the following forEach result with values from another array but I can't get it working.



const BbDescriptionDictionary = ['AAA' , 'BBB', 'CCC',] 
const boardBasisOptionsModified = ;

this.boardBasisOptions.forEach( (value) => {
boardBasisOptionsModified.push({
"key": value, "value": BbDescriptionDictionary[value]
});
});

this.boardBasisOptions = boardBasisOptionsModified;









share|improve this question
























  • what is boardBasisOptions?
    – Pardeep Jain
    Nov 22 at 10:38










  • btw, your dictionary is an array, that means you access it with an index, not a value.
    – Nina Scholz
    Nov 22 at 10:39










  • value is an item in the array "boardBasisOptions"... while you should provide an indexNumber to "BbDescriptionDictionary[value]"...
    – AIqbalRaj
    Nov 22 at 10:40






  • 1




    You array works with indexes, not named properties. Using BbDescriptionDictionary[value] will translate to BbDescriptionDictionary['AAA'], while it should be BbDescriptionDictionary[0].
    – trichetriche
    Nov 22 at 10:40
















2














I want to modify the following forEach result with values from another array but I can't get it working.



const BbDescriptionDictionary = ['AAA' , 'BBB', 'CCC',] 
const boardBasisOptionsModified = ;

this.boardBasisOptions.forEach( (value) => {
boardBasisOptionsModified.push({
"key": value, "value": BbDescriptionDictionary[value]
});
});

this.boardBasisOptions = boardBasisOptionsModified;









share|improve this question
























  • what is boardBasisOptions?
    – Pardeep Jain
    Nov 22 at 10:38










  • btw, your dictionary is an array, that means you access it with an index, not a value.
    – Nina Scholz
    Nov 22 at 10:39










  • value is an item in the array "boardBasisOptions"... while you should provide an indexNumber to "BbDescriptionDictionary[value]"...
    – AIqbalRaj
    Nov 22 at 10:40






  • 1




    You array works with indexes, not named properties. Using BbDescriptionDictionary[value] will translate to BbDescriptionDictionary['AAA'], while it should be BbDescriptionDictionary[0].
    – trichetriche
    Nov 22 at 10:40














2












2








2







I want to modify the following forEach result with values from another array but I can't get it working.



const BbDescriptionDictionary = ['AAA' , 'BBB', 'CCC',] 
const boardBasisOptionsModified = ;

this.boardBasisOptions.forEach( (value) => {
boardBasisOptionsModified.push({
"key": value, "value": BbDescriptionDictionary[value]
});
});

this.boardBasisOptions = boardBasisOptionsModified;









share|improve this question















I want to modify the following forEach result with values from another array but I can't get it working.



const BbDescriptionDictionary = ['AAA' , 'BBB', 'CCC',] 
const boardBasisOptionsModified = ;

this.boardBasisOptions.forEach( (value) => {
boardBasisOptionsModified.push({
"key": value, "value": BbDescriptionDictionary[value]
});
});

this.boardBasisOptions = boardBasisOptionsModified;






javascript angular






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 22 at 10:39









cyr-x

7,118932




7,118932










asked Nov 22 at 10:36









olootu

2416




2416












  • what is boardBasisOptions?
    – Pardeep Jain
    Nov 22 at 10:38










  • btw, your dictionary is an array, that means you access it with an index, not a value.
    – Nina Scholz
    Nov 22 at 10:39










  • value is an item in the array "boardBasisOptions"... while you should provide an indexNumber to "BbDescriptionDictionary[value]"...
    – AIqbalRaj
    Nov 22 at 10:40






  • 1




    You array works with indexes, not named properties. Using BbDescriptionDictionary[value] will translate to BbDescriptionDictionary['AAA'], while it should be BbDescriptionDictionary[0].
    – trichetriche
    Nov 22 at 10:40


















  • what is boardBasisOptions?
    – Pardeep Jain
    Nov 22 at 10:38










  • btw, your dictionary is an array, that means you access it with an index, not a value.
    – Nina Scholz
    Nov 22 at 10:39










  • value is an item in the array "boardBasisOptions"... while you should provide an indexNumber to "BbDescriptionDictionary[value]"...
    – AIqbalRaj
    Nov 22 at 10:40






  • 1




    You array works with indexes, not named properties. Using BbDescriptionDictionary[value] will translate to BbDescriptionDictionary['AAA'], while it should be BbDescriptionDictionary[0].
    – trichetriche
    Nov 22 at 10:40
















what is boardBasisOptions?
– Pardeep Jain
Nov 22 at 10:38




what is boardBasisOptions?
– Pardeep Jain
Nov 22 at 10:38












btw, your dictionary is an array, that means you access it with an index, not a value.
– Nina Scholz
Nov 22 at 10:39




btw, your dictionary is an array, that means you access it with an index, not a value.
– Nina Scholz
Nov 22 at 10:39












value is an item in the array "boardBasisOptions"... while you should provide an indexNumber to "BbDescriptionDictionary[value]"...
– AIqbalRaj
Nov 22 at 10:40




value is an item in the array "boardBasisOptions"... while you should provide an indexNumber to "BbDescriptionDictionary[value]"...
– AIqbalRaj
Nov 22 at 10:40




1




1




You array works with indexes, not named properties. Using BbDescriptionDictionary[value] will translate to BbDescriptionDictionary['AAA'], while it should be BbDescriptionDictionary[0].
– trichetriche
Nov 22 at 10:40




You array works with indexes, not named properties. Using BbDescriptionDictionary[value] will translate to BbDescriptionDictionary['AAA'], while it should be BbDescriptionDictionary[0].
– trichetriche
Nov 22 at 10:40












5 Answers
5






active

oldest

votes


















0














You may want to add the index parameter in your forEach loop:

(I also initialized the boardBasisOptions with some values)



See this working snippet:




boardBasisOptions = ['key1', 'key2', 'key3'];
const BbDescriptionDictionary = ['AAA', 'BBB', 'CCC', ]
const boardBasisOptionsModified = ;

this.boardBasisOptions.forEach((value, index) => {
boardBasisOptionsModified.push({
"key": value,
"value": BbDescriptionDictionary[index]
});
});

this.boardBasisOptions = boardBasisOptionsModified;

console.log("boardBasisOptions:");
console.log(this.boardBasisOptions);








share|improve this answer























  • For the sake of example you should log boardBasisOptionsModified.
    – Darren
    Nov 22 at 10:42










  • @Darren I think there is no need, I already log boardBasisOptions !
    – Takit Isy
    Nov 22 at 10:44










  • It works perfectly. Many thanks.
    – olootu
    Nov 22 at 10:58



















2














You can give .forEach a second parameter, indicating the index of boardBasisOptions. Like this:



this.boardBasisOptions.forEach( (value, index) => {
boardBasisOptionsModified.push({
"key": value, "value": BbDescriptionDictionary[index]
});
});





share|improve this answer





























    0














    You're trying to access the value inside your BbDescriptionDictionay array using the value and not the index. You have to use the index to access the value of an array.



    Just add index as a second parameter of your forEach function.



    this.boardBasisOptions.forEach( (value, index) => {
    boardBasisOptionsModified.push({
    "key": value, "value": BbDescriptionDictionary[index]
    });
    });





    share|improve this answer





























      0














      By taking the index, you could use Array#map instead of Array#push.



      const BbDescriptionDictionary = ['AAA', 'BBB', 'CCC',] 

      this.boardBasisOptions = this
      .boardBasisOptions
      .map((key, index) => ({ key, value: BbDescriptionDictionary[index] }));





      share|improve this answer





























        0














        You should just use Array.prototype.map() to create a new, mutated array rather than worrying about creating temporary arrays, mutating them and then assigning them.



        const BbDescriptionDictionary = ['AAA' , 'BBB', 'CCC',] 

        // Map runs the function on each array item and returns a new array
        // with mutated the return value of that function
        // Note: ({ ... }) is a shorthand way of returning a value
        // (object in this case) without a function body {}
        this.boardBasisOptions = this.boardBasisOptions.map((key, index) => ({
        // Shorthand way of assigning a variable to an object using the var
        // name as the key
        key,
        value: BbDescriptionDictionary[index]
        })


        Its is considered bad practice to override properties like this, so I would return the original boardBasisOptions to a a new property and use that later on:



        const BbDescriptionDictionary = ['AAA' , 'BBB', 'CCC',] 

        this.boardBasisOptionsWithDescriptions = this.boardBasisOptions.map((key, index) => ({
        key,
        value: BbDescriptionDictionary[index]
        })


        Hope that helps 👍






        share|improve this answer























          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53429013%2fmodify-javascript-foreach-result-with-value-from-another-array%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          5 Answers
          5






          active

          oldest

          votes








          5 Answers
          5






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          You may want to add the index parameter in your forEach loop:

          (I also initialized the boardBasisOptions with some values)



          See this working snippet:




          boardBasisOptions = ['key1', 'key2', 'key3'];
          const BbDescriptionDictionary = ['AAA', 'BBB', 'CCC', ]
          const boardBasisOptionsModified = ;

          this.boardBasisOptions.forEach((value, index) => {
          boardBasisOptionsModified.push({
          "key": value,
          "value": BbDescriptionDictionary[index]
          });
          });

          this.boardBasisOptions = boardBasisOptionsModified;

          console.log("boardBasisOptions:");
          console.log(this.boardBasisOptions);








          share|improve this answer























          • For the sake of example you should log boardBasisOptionsModified.
            – Darren
            Nov 22 at 10:42










          • @Darren I think there is no need, I already log boardBasisOptions !
            – Takit Isy
            Nov 22 at 10:44










          • It works perfectly. Many thanks.
            – olootu
            Nov 22 at 10:58
















          0














          You may want to add the index parameter in your forEach loop:

          (I also initialized the boardBasisOptions with some values)



          See this working snippet:




          boardBasisOptions = ['key1', 'key2', 'key3'];
          const BbDescriptionDictionary = ['AAA', 'BBB', 'CCC', ]
          const boardBasisOptionsModified = ;

          this.boardBasisOptions.forEach((value, index) => {
          boardBasisOptionsModified.push({
          "key": value,
          "value": BbDescriptionDictionary[index]
          });
          });

          this.boardBasisOptions = boardBasisOptionsModified;

          console.log("boardBasisOptions:");
          console.log(this.boardBasisOptions);








          share|improve this answer























          • For the sake of example you should log boardBasisOptionsModified.
            – Darren
            Nov 22 at 10:42










          • @Darren I think there is no need, I already log boardBasisOptions !
            – Takit Isy
            Nov 22 at 10:44










          • It works perfectly. Many thanks.
            – olootu
            Nov 22 at 10:58














          0












          0








          0






          You may want to add the index parameter in your forEach loop:

          (I also initialized the boardBasisOptions with some values)



          See this working snippet:




          boardBasisOptions = ['key1', 'key2', 'key3'];
          const BbDescriptionDictionary = ['AAA', 'BBB', 'CCC', ]
          const boardBasisOptionsModified = ;

          this.boardBasisOptions.forEach((value, index) => {
          boardBasisOptionsModified.push({
          "key": value,
          "value": BbDescriptionDictionary[index]
          });
          });

          this.boardBasisOptions = boardBasisOptionsModified;

          console.log("boardBasisOptions:");
          console.log(this.boardBasisOptions);








          share|improve this answer














          You may want to add the index parameter in your forEach loop:

          (I also initialized the boardBasisOptions with some values)



          See this working snippet:




          boardBasisOptions = ['key1', 'key2', 'key3'];
          const BbDescriptionDictionary = ['AAA', 'BBB', 'CCC', ]
          const boardBasisOptionsModified = ;

          this.boardBasisOptions.forEach((value, index) => {
          boardBasisOptionsModified.push({
          "key": value,
          "value": BbDescriptionDictionary[index]
          });
          });

          this.boardBasisOptions = boardBasisOptionsModified;

          console.log("boardBasisOptions:");
          console.log(this.boardBasisOptions);








          boardBasisOptions = ['key1', 'key2', 'key3'];
          const BbDescriptionDictionary = ['AAA', 'BBB', 'CCC', ]
          const boardBasisOptionsModified = ;

          this.boardBasisOptions.forEach((value, index) => {
          boardBasisOptionsModified.push({
          "key": value,
          "value": BbDescriptionDictionary[index]
          });
          });

          this.boardBasisOptions = boardBasisOptionsModified;

          console.log("boardBasisOptions:");
          console.log(this.boardBasisOptions);





          boardBasisOptions = ['key1', 'key2', 'key3'];
          const BbDescriptionDictionary = ['AAA', 'BBB', 'CCC', ]
          const boardBasisOptionsModified = ;

          this.boardBasisOptions.forEach((value, index) => {
          boardBasisOptionsModified.push({
          "key": value,
          "value": BbDescriptionDictionary[index]
          });
          });

          this.boardBasisOptions = boardBasisOptionsModified;

          console.log("boardBasisOptions:");
          console.log(this.boardBasisOptions);






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 26 at 9:27









          halfer

          14.3k758108




          14.3k758108










          answered Nov 22 at 10:40









          Takit Isy

          6,0552930




          6,0552930












          • For the sake of example you should log boardBasisOptionsModified.
            – Darren
            Nov 22 at 10:42










          • @Darren I think there is no need, I already log boardBasisOptions !
            – Takit Isy
            Nov 22 at 10:44










          • It works perfectly. Many thanks.
            – olootu
            Nov 22 at 10:58


















          • For the sake of example you should log boardBasisOptionsModified.
            – Darren
            Nov 22 at 10:42










          • @Darren I think there is no need, I already log boardBasisOptions !
            – Takit Isy
            Nov 22 at 10:44










          • It works perfectly. Many thanks.
            – olootu
            Nov 22 at 10:58
















          For the sake of example you should log boardBasisOptionsModified.
          – Darren
          Nov 22 at 10:42




          For the sake of example you should log boardBasisOptionsModified.
          – Darren
          Nov 22 at 10:42












          @Darren I think there is no need, I already log boardBasisOptions !
          – Takit Isy
          Nov 22 at 10:44




          @Darren I think there is no need, I already log boardBasisOptions !
          – Takit Isy
          Nov 22 at 10:44












          It works perfectly. Many thanks.
          – olootu
          Nov 22 at 10:58




          It works perfectly. Many thanks.
          – olootu
          Nov 22 at 10:58













          2














          You can give .forEach a second parameter, indicating the index of boardBasisOptions. Like this:



          this.boardBasisOptions.forEach( (value, index) => {
          boardBasisOptionsModified.push({
          "key": value, "value": BbDescriptionDictionary[index]
          });
          });





          share|improve this answer


























            2














            You can give .forEach a second parameter, indicating the index of boardBasisOptions. Like this:



            this.boardBasisOptions.forEach( (value, index) => {
            boardBasisOptionsModified.push({
            "key": value, "value": BbDescriptionDictionary[index]
            });
            });





            share|improve this answer
























              2












              2








              2






              You can give .forEach a second parameter, indicating the index of boardBasisOptions. Like this:



              this.boardBasisOptions.forEach( (value, index) => {
              boardBasisOptionsModified.push({
              "key": value, "value": BbDescriptionDictionary[index]
              });
              });





              share|improve this answer












              You can give .forEach a second parameter, indicating the index of boardBasisOptions. Like this:



              this.boardBasisOptions.forEach( (value, index) => {
              boardBasisOptionsModified.push({
              "key": value, "value": BbDescriptionDictionary[index]
              });
              });






              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Nov 22 at 10:40









              Darren

              517410




              517410























                  0














                  You're trying to access the value inside your BbDescriptionDictionay array using the value and not the index. You have to use the index to access the value of an array.



                  Just add index as a second parameter of your forEach function.



                  this.boardBasisOptions.forEach( (value, index) => {
                  boardBasisOptionsModified.push({
                  "key": value, "value": BbDescriptionDictionary[index]
                  });
                  });





                  share|improve this answer


























                    0














                    You're trying to access the value inside your BbDescriptionDictionay array using the value and not the index. You have to use the index to access the value of an array.



                    Just add index as a second parameter of your forEach function.



                    this.boardBasisOptions.forEach( (value, index) => {
                    boardBasisOptionsModified.push({
                    "key": value, "value": BbDescriptionDictionary[index]
                    });
                    });





                    share|improve this answer
























                      0












                      0








                      0






                      You're trying to access the value inside your BbDescriptionDictionay array using the value and not the index. You have to use the index to access the value of an array.



                      Just add index as a second parameter of your forEach function.



                      this.boardBasisOptions.forEach( (value, index) => {
                      boardBasisOptionsModified.push({
                      "key": value, "value": BbDescriptionDictionary[index]
                      });
                      });





                      share|improve this answer












                      You're trying to access the value inside your BbDescriptionDictionay array using the value and not the index. You have to use the index to access the value of an array.



                      Just add index as a second parameter of your forEach function.



                      this.boardBasisOptions.forEach( (value, index) => {
                      boardBasisOptionsModified.push({
                      "key": value, "value": BbDescriptionDictionary[index]
                      });
                      });






                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Nov 22 at 10:41









                      cyr-x

                      7,118932




                      7,118932























                          0














                          By taking the index, you could use Array#map instead of Array#push.



                          const BbDescriptionDictionary = ['AAA', 'BBB', 'CCC',] 

                          this.boardBasisOptions = this
                          .boardBasisOptions
                          .map((key, index) => ({ key, value: BbDescriptionDictionary[index] }));





                          share|improve this answer


























                            0














                            By taking the index, you could use Array#map instead of Array#push.



                            const BbDescriptionDictionary = ['AAA', 'BBB', 'CCC',] 

                            this.boardBasisOptions = this
                            .boardBasisOptions
                            .map((key, index) => ({ key, value: BbDescriptionDictionary[index] }));





                            share|improve this answer
























                              0












                              0








                              0






                              By taking the index, you could use Array#map instead of Array#push.



                              const BbDescriptionDictionary = ['AAA', 'BBB', 'CCC',] 

                              this.boardBasisOptions = this
                              .boardBasisOptions
                              .map((key, index) => ({ key, value: BbDescriptionDictionary[index] }));





                              share|improve this answer












                              By taking the index, you could use Array#map instead of Array#push.



                              const BbDescriptionDictionary = ['AAA', 'BBB', 'CCC',] 

                              this.boardBasisOptions = this
                              .boardBasisOptions
                              .map((key, index) => ({ key, value: BbDescriptionDictionary[index] }));






                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Nov 22 at 10:50









                              Nina Scholz

                              174k1387151




                              174k1387151























                                  0














                                  You should just use Array.prototype.map() to create a new, mutated array rather than worrying about creating temporary arrays, mutating them and then assigning them.



                                  const BbDescriptionDictionary = ['AAA' , 'BBB', 'CCC',] 

                                  // Map runs the function on each array item and returns a new array
                                  // with mutated the return value of that function
                                  // Note: ({ ... }) is a shorthand way of returning a value
                                  // (object in this case) without a function body {}
                                  this.boardBasisOptions = this.boardBasisOptions.map((key, index) => ({
                                  // Shorthand way of assigning a variable to an object using the var
                                  // name as the key
                                  key,
                                  value: BbDescriptionDictionary[index]
                                  })


                                  Its is considered bad practice to override properties like this, so I would return the original boardBasisOptions to a a new property and use that later on:



                                  const BbDescriptionDictionary = ['AAA' , 'BBB', 'CCC',] 

                                  this.boardBasisOptionsWithDescriptions = this.boardBasisOptions.map((key, index) => ({
                                  key,
                                  value: BbDescriptionDictionary[index]
                                  })


                                  Hope that helps 👍






                                  share|improve this answer




























                                    0














                                    You should just use Array.prototype.map() to create a new, mutated array rather than worrying about creating temporary arrays, mutating them and then assigning them.



                                    const BbDescriptionDictionary = ['AAA' , 'BBB', 'CCC',] 

                                    // Map runs the function on each array item and returns a new array
                                    // with mutated the return value of that function
                                    // Note: ({ ... }) is a shorthand way of returning a value
                                    // (object in this case) without a function body {}
                                    this.boardBasisOptions = this.boardBasisOptions.map((key, index) => ({
                                    // Shorthand way of assigning a variable to an object using the var
                                    // name as the key
                                    key,
                                    value: BbDescriptionDictionary[index]
                                    })


                                    Its is considered bad practice to override properties like this, so I would return the original boardBasisOptions to a a new property and use that later on:



                                    const BbDescriptionDictionary = ['AAA' , 'BBB', 'CCC',] 

                                    this.boardBasisOptionsWithDescriptions = this.boardBasisOptions.map((key, index) => ({
                                    key,
                                    value: BbDescriptionDictionary[index]
                                    })


                                    Hope that helps 👍






                                    share|improve this answer


























                                      0












                                      0








                                      0






                                      You should just use Array.prototype.map() to create a new, mutated array rather than worrying about creating temporary arrays, mutating them and then assigning them.



                                      const BbDescriptionDictionary = ['AAA' , 'BBB', 'CCC',] 

                                      // Map runs the function on each array item and returns a new array
                                      // with mutated the return value of that function
                                      // Note: ({ ... }) is a shorthand way of returning a value
                                      // (object in this case) without a function body {}
                                      this.boardBasisOptions = this.boardBasisOptions.map((key, index) => ({
                                      // Shorthand way of assigning a variable to an object using the var
                                      // name as the key
                                      key,
                                      value: BbDescriptionDictionary[index]
                                      })


                                      Its is considered bad practice to override properties like this, so I would return the original boardBasisOptions to a a new property and use that later on:



                                      const BbDescriptionDictionary = ['AAA' , 'BBB', 'CCC',] 

                                      this.boardBasisOptionsWithDescriptions = this.boardBasisOptions.map((key, index) => ({
                                      key,
                                      value: BbDescriptionDictionary[index]
                                      })


                                      Hope that helps 👍






                                      share|improve this answer














                                      You should just use Array.prototype.map() to create a new, mutated array rather than worrying about creating temporary arrays, mutating them and then assigning them.



                                      const BbDescriptionDictionary = ['AAA' , 'BBB', 'CCC',] 

                                      // Map runs the function on each array item and returns a new array
                                      // with mutated the return value of that function
                                      // Note: ({ ... }) is a shorthand way of returning a value
                                      // (object in this case) without a function body {}
                                      this.boardBasisOptions = this.boardBasisOptions.map((key, index) => ({
                                      // Shorthand way of assigning a variable to an object using the var
                                      // name as the key
                                      key,
                                      value: BbDescriptionDictionary[index]
                                      })


                                      Its is considered bad practice to override properties like this, so I would return the original boardBasisOptions to a a new property and use that later on:



                                      const BbDescriptionDictionary = ['AAA' , 'BBB', 'CCC',] 

                                      this.boardBasisOptionsWithDescriptions = this.boardBasisOptions.map((key, index) => ({
                                      key,
                                      value: BbDescriptionDictionary[index]
                                      })


                                      Hope that helps 👍







                                      share|improve this answer














                                      share|improve this answer



                                      share|improve this answer








                                      edited Nov 22 at 10:58

























                                      answered Nov 22 at 10:53









                                      Stuart Wilson

                                      613




                                      613






























                                          draft saved

                                          draft discarded




















































                                          Thanks for contributing an answer to Stack Overflow!


                                          • Please be sure to answer the question. Provide details and share your research!

                                          But avoid



                                          • Asking for help, clarification, or responding to other answers.

                                          • Making statements based on opinion; back them up with references or personal experience.


                                          To learn more, see our tips on writing great answers.





                                          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                          Please pay close attention to the following guidance:


                                          • Please be sure to answer the question. Provide details and share your research!

                                          But avoid



                                          • Asking for help, clarification, or responding to other answers.

                                          • Making statements based on opinion; back them up with references or personal experience.


                                          To learn more, see our tips on writing great answers.




                                          draft saved


                                          draft discarded














                                          StackExchange.ready(
                                          function () {
                                          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53429013%2fmodify-javascript-foreach-result-with-value-from-another-array%23new-answer', 'question_page');
                                          }
                                          );

                                          Post as a guest















                                          Required, but never shown





















































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown

































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown







                                          Popular posts from this blog

                                          Berounka

                                          Sphinx de Gizeh

                                          Different font size/position of beamer's navigation symbols template's content depending on regular/plain...