forEach loop not updating array as desired

I’m trying to loop through the consoleOuputParamsOBJ and update a record in my taskparamscompiled list of objects

consoleOuputParamsOBJ

"outputParameters": [
        {
            "name": "00x00",
            "filepath": "D:\\Code\\UnitTest\\ConsoleApp\\1\\00x00.png"
        },
        {
            "name": "00x01",
            "filepath": "D:\\Code\\UnitTest\\ConsoleApp\\1\\00x01.png"
        },
        {
            "name": "00x02",
            "filepath": "D:\\Code\\UnitTest\\ConsoleApp\\1\\00x02.png"
        },

taskparamscompiled updated with current output, it’s updating all the records with the last instance of the record in the consoleOuptutParamsOBJ. I’m trying to get them to update with the correct matching filepath

{
    "process00x00": {
        "-i": "D:\\Code\\UnitTest\\ConsoleApp\\1\\13x23.png",
        "-tr": 16,
        "-tc": 16,
        "-ofr": 16,
        "-ofc": 16,
        "-outfile": "\"D:\\Code\\UnitTest\\ConsoleApp\\Process\\1\""
    },
    "process00x01": {
        "-i": "D:\\Code\\UnitTest\\ConsoleApp\\1\\13x23.png",
        "-tr": 16,
        "-tc": 16,
        "-ofr": 16,
        "-ofc": 16,
        "-outfile": "\"D:\\Code\\UnitTest\\ConsoleApp\\Process\\1\""
    },
    "process00x02": {
        "-i": "D:\\Code\\UnitTest\\ConsoleApp\\1\\13x23.png",
        "-tr": 16,
        "-tc": 16,
        "-ofr": 16,
        "-ofc": 16,
        "-outfile": "\"D:\\Code\\UnitTest\\ConsoleApp\\Process\\1\""
    },

What i’m currently doing, the processname seems to be working since it’s updating that value but the data it’s using to update it with is only the last record from the taskparamscompiled dataset.

 consoleOutputParamsOBJ.forEach((obj) => {
      var processname = dynamicTaskNameBaseOBJ + obj.name;
      filepath = obj.filepath;
      taskparamscompiled[processname]['-i'] = filepath;


    });

20 thoughts on “forEach loop not updating array as desired”

  1. Hi! I understand this is sort of off-topic however I needed to ask.
    Does managing a well-established website such as yours
    take a lot of work? I am completely new to running a blog
    but I do write in my journal on a daily basis. I’d like to start
    a blog so I will be able to share my own experience and
    thoughts online. Please let me know if you have any recommendations or tips for brand new aspiring bloggers.
    Appreciate it! http://www.deinformedvoters.org/hydroxychloroquine

    Reply
  2. 858261 790283Be the precise weblog in the event you have wants to learn about this topic. You comprehend considerably its almost onerous to argue to you (not that I personally would needHaHa). You undoubtedly put a new spin for a subject thats been discussing for some time. Nice stuff, merely nice! 26963

    Reply
  3. 680278 403190Can I just now say that of a relief to locate somebody who truly knows what theyre speaking about online. You really know how to bring a difficulty to light and function out it crucial. The diet need to have to see this and appreciate this side on the story. I cant believe youre no far more popular since you certainly possess the gift. 727007

    Reply
  4. 37716 265415Youre so cool! I dont suppose Ive read anything in this way before. So nice to uncover somebody with some original tips on this topic. realy appreciate starting this up. this exceptional website is something that is required more than the internet, a person if we do originality. valuable work for bringing something new towards the internet! 712607

    Reply

Leave a Comment