Skip to content

Tag: arrays

Using UseState in Reactjs

I am trying to map the values of userIDs to listUserIds, and then use values of listUserIds as keys in listUser function. But it only show the last value. What did I go wrong? } Answer You can set the values like this. using map you can collect all the ids then you can update the state.

Counting the occurrences in an array

I have a simple array such as: I want to display the element that has the highest occurrence, in this case “Jalkatreeni”. How should I go about doing it? Any neat tips are appreciated. 🙂 Thank you in advance! Answer Try the following. You can iterate through your array using .reduce(). In each ite…

create new array from nested array object

i want to create a new array from api, but i don’t know how to make it, i’m very confused in looping each array This is each data this is the main data of api i want to create a new array like this, bcs i want to create a new object containing the group_id of each same data in