How do I read in data from a CSV file in HTML/CSS/JS, and then access that data?

I want to be able to have the user input a guess for a soccer player, and then check whether there is correct. The correct player will be randomly chosen from the csv file, and then I want to check whether that name watches with the user’s guess. Attached is my code thus far.

I tried messing with the nature of the correctName variable, including making it global. I also have the document.write(correctName), but all that prints out for me is “undefined”.

first half of code
second half of code