I have an array map with json objects in javascript, the map consists of a title and list items, for list item Amount i use add and minus button, to change values in Amount, how can i change the values in the html but for each one object only?
I’m not sure I understand completely, but I would expect that that add function needs to know what element in the array on which it is acting. Maybe you could encode that information in the button with a value prop? Or maybe there is some other way to figure it out from the info coming in on the event.
Sure, I forgot that you can just pass that in the function - I forgot you could pass values like that in HTML (I’ve been in React Native world too long). Why idx? Because it will identify which element in the array needs adjusting.
Yeah, probably something like that. Although, since you are passing it directly, you can probably just pass the index and receive it as the parameter in the add function.
How can I add the number to the parameter, becuz i dont want to only add the amount, but by increasing the amount other list items, should also change?
You’re going to have to be more specific. What does “number” mean in that sentence. And I’m not sure what the rest of that sentence means. What do you want that button to do and what information does it need to accomplish that?
By number i meant the amount, means the amount is now set on the value it has in the json file, by clicking on the add button, the amount adds 1 value, means from 1 to 2, but it also by incresing amount increases for example the protein/fat value (not by one but by value)…
1bread = 23g fat
2bread = 46g fat
What i dont know is how to increase the values like that for each good/element