I've written some code that looks like:
state.intro = state.memoryCards[Math.floor(Math.random() * state.memoryCards.length)];
I don't think this is the right way to mutate the state, so I was refactoring the code below, but i am not sure how to return one index of that memoryCards array.
intro: state.memoryCards.find(function(card, index) {
const randomIndex = Math.floor(Math.random() * state.memoryCards.length);
if(index === randomIndex) {
return card
}
})
statethe state of a React component?