no worries. Okay, I've fixed your code, but I honestly think it'd be better if you figured it out. I'd be doing you a disservice if I just pushed the fixed code to your repo and went about my day. I'll get you on the right track and if you end up feeling like putting your fist through a wall or breaking your monitor, I'll lead you through my solution. You seem like a cool guy and I genuinely want you to get better so please don't think I'm insulting you, I'm not! This feedback is all constructive and written with love.
The first thing I did was clean up your code -- to be honest its a bit messy. You know when you clean your desk/setup up and things start to make more sense? I would start by cleaning up your code. It'll allow you to really look and figure things out in a much more simple way.
Some of your implementations are also a bit interesting. For example, you run the function at the top and then export it at the bottom. I don't think this is a serious issue but typically react components are structured with the whole thing all in one line at the top
return(
//JSX
)
}
I'd really take a hard look at your code and think to yourself "Am I doing this in a way that is just a bit funky? Are any of my implementations a little silly?". Another example is how you use the playAgain function. To be honest, my solution involved scrapping that function in favor of something else. That whole interaction seemed super funky to me.
The solution is actually pretty simple, I was struggling with it for awhile, and kinda facepalmed when I realized -- it was right in front of our face! Hint: it has to do with fetch and how chained promises work. (Another hint: I wouldn't have been able to see it if I didn't do some serious janitorial work first -- I couldn't find the "bug" with all the clutter!). As many programming projects go, from novice to expert, its 1 line causing you issues.
The second part of the solution is making sure you're not mapping over an array that doesn't exist. The error "... is not an object" is caused by react going "hey man! you told me I was supposed to be mapping over an array, and there is no array here! what the heck!". A bit of a hint there: use the ? operator like how I explained before.
Good luck! I know you can do it 🙂