im making a js webpage that takes an uploaded text file and then puts the content of the text file into a variable. From here I can do what I need with the data. My problem is that I cannot get the data into the variable. I can log it to the console, but not into a variable.
unction getFile(inputId) {
  const selectedFile = document.getElementById(inputId).files[0];
  console.log(selectedFile)
  let read = new FileReader()
  read.readAsText(selectedFile)
  let text = ''
  read.onload = function(event) {
    text = event.target.result
    console.log(text)
  }
  text = event.target.result
  console.log(text)
  return text
}
In the code you notice two console.logs. The first one works, but the second does not. It just prints ''
