'Randomizing elements in an array in Typescript giving error: TypeError: 0 is read-only
I have an array of objects, and I'd like to randomize the order of the elements.
So I have the following:
const animals = data?.fetchAllAnimals;
let randomizeAnimals = animals.sort(()=> Math.random() -0.5 )
But I keep getting this error in firefox:
TypeError: 0 is read-only
and a different error in chrome:
TypeError: Cannot assign to read only property '0' of object '[object Array]'
What am I doing wrong here?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
