I am trying to have a code that will return a random sentence from an array. Kind of like a random quote machine except it’s 3 different quotes on the page at the same time. Here’s how it looks
<div className="">
{this.state.first.map((first) => (
<div className="">{first}</div>
))}
</div>
<div className="">
{this.state.second.map((second) => (
<div className="">{second}</div>
))}
</div>
<div className="">
{this.state.third.map((third) => (
<div className="">{third}</div>
))}
</div>
What I want to do is have the map function only return one from each array. I tried this by doing this.
{this.state.first.map((first) => (
<div className="">{first[0]}</div>
))}
This gave me the first letter from each sentence. But what am I missing to have it give me the whole sentence returning instead of just the first letter?
The whole code is viewable here
https://github.com/Imstupidpleasehelp/CovidConspiracyGenerator/blob/master/src/Slotmachine.jsx
Thank you in advance for your input.
Edit for clarification. I want to have a random index of each array display to the page when a user presses a button. I already have a function that will give me a random number between 1 and 10. I want to be able to have it work like a random quote machine.