Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

161
Views
JavaScript - how to access the value of a declared variable outside it's function

I've seen a few similar questions asked, but couldn't get them to work with my code so just wanted to see if I could get some additional help - my code below:

const upload(input, file){

  var fileUploadedCorrectly = true

  file.onload = (e) =>{
   if(code checking if extension is .csv){
      fileUploadedCorrectly = true;
    } else {
      fileUploadedCorrectly = false;
    }
   }
}

function retrieve(in){
  const file = in.files[0];

  if (fileUploadedCorrectly){
   code to continue upload
  } else {
   code to display error message
  }
}

I'm having trouble with accessing the value of fileUploadedCorrectly in the retrieve() function. Any help would be much appreciated - thank you very much.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!