You are reading a single comment by @Primata and its replies.
Click here to read the full conversation.
-
Why is the index not replaced?
the function inside
menuObjekt[key] = function(){showSettings(tempArray[i])};
is just defined but not evaluated inside the loop. Only later when function is called it is really evaluated so only thentempArray
andi
variable values are read.You would need to store value of tempArray[i] into the menuObjekt or somewhere else directly in the loop.
Hello,
I am trying to create a Bangle.js app for my gym training plan.
I have an interface for the app loader where I create the training plan, this is an Array of json objects.
Now I want to create a menu, where I can select a machine which has not been finished.
The keys are shown correct, but the function to get the settings view does not work.
The output for consol.log(mainmenu); is:
Why is the index not replaced?
I tried a lot of stuff, but don't understand my problem.
Neither my programming skills nor my English are very good, so I don't get the problem.
The web ide is warning me, that functions declared within loops may lead to confusing semantics, but I don't see another way?
There may be a different amount of machines I want to train, and I want only the machines to be in the machines I haven't finished.
Thank you in advance for your help and patience.
Tobi