How to get the contents of my Keys ascending order array

Asked

Viewed 37 times

0

I’m having a problem with a function of an app I’m creating. I am a mere beginner in programming seeking to improve my knowledge and wanted to know how to make my function take the contents of the Keys of my array in ascending order of these.

Example:

var exemplo = {
    "1":"chave1",
    "2":"chave2",
    "3":"chave3"
}

In that case, I wanted him to get the contents of the Keys in order and, upon reaching the last key, return to the first in creating a loop.

Thus, returning the value of my key "1", after "2" and "3", going back to the beginning and repeating the process. It is a more useful method than taking a value Random using the Math since I wanted it to be in order and not randomly.

  • How did you try to do it? Post your code next to the question and describe the problem you are having.

  • It’s not very clear to me what you’re trying to do and what the ultimate goal is.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.