0

I need to shuffle this array every 10 seconds By object ID. Here I have only 5 entities but I need to do this for n entity.

[{
    "id": "5",
    "name": "Got",
    "price": 170
  },
  {
    "id": "1",
    "name": "Cat",
    "price": 170
  },
  {
    "id": "2",
    "name": "Dog",
    "price": 270
  },
  {
    "id": "3",
    "name": "Cow",
    "price": 70
  },
  {
    "id": "4",
    "name": "Ant",
    "price": 170
  }]

I have tried this.. This function not giving actual output

startRandom() {
    if (this.rndm) {
        this.temData = []
        for (i = 0; i <= 10; i++) {

            this.temData.push(this.tempData[Math.floor(Math.random() * 10) + 1  ])
        }
        this.tempData = this.temData
    }
},

0 Answers0