I want to pick an item from an array but randomly. The problem is that the indexes of the array are string. How can I select an item from this array but with a random index.
Nb: Indexes are string, I found answers with integer indexes but not string.
//................................................
const styles = StyleSheet.create({
bigBlue: {
color: 'blue',
fontWeight: 'bold',
fontSize: 30,
},
red: {
color: 'red',
},
});
//.......................................................
return (
//if index was integer
<Text style={styles[Math.floor(Math.random()*styles.length)]}>{this.props.text}</Text>
// I need something like this : styles[RandomStringIndex()]
);