Skip to content

Tag: arrays

push() removing previous values

I’m trying to push new values to an array but all I’m getting is only the last value computed. I’ve looked at other answers but couldn’t seem to figure it out. I appreciate the help thanks. brief: upon clicking start I set a new date, then upon each time I click on the square div, the …

How can I sort this array in Discord.js?

I have an array, that looks like this(size changes): The first value is the member id, the second how many messages the user has. How can I sort the array, to get the first 10 members, sorted by their messages send? The code: Answer To sort an array by numbers, you can use the .sort() method with a compare fu…

Join specific items in an array [closed]

Closed. This question needs debugging details. It is not currently accepting answers. Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question. Closed 1 year ago. Improve this question I woul…

Increment array up to max items

I’ve written this code. It rotates two divs like a card flip using css transform every 1000ms and displays new text in the div, which is drawn from an array. It runs infinitely. But once the array reaches its end I get an ‘undefined’ value because the i++ is incrementing on the final array i…