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

290
Views
A function to execute two functions but only one executes?

I have tried using a function to execute two functions when the page loads using window.onload, the issue I am having is that the function (myFunc) only executes the first function from the top (Func1) but not (Func2), the function looks like this

window.onload = function myFunc(){
    return Func1(); 
    return Func2(); 
} 

So how can I execute both of them?

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

Try this :)

make sure you define Functions before calling them, this is good practice

//Arrow function and remove the return

const Func1 = () => {
  console.log('This is Func1');
}
const Func2 = () => {
  console.log('This is Func2');
}

window.onload = myFunc = () => {
  Func1();
  Func2();
}

about 4 years ago · Juan Pablo Isaza Report

0

do not return because after return goes out of function

window.onload = function myFunc(){
    Func1(); 
    Func2(); 
}
about 4 years ago · Juan Pablo Isaza Report

0

Remove the return keywords, and just run the function as is.

about 4 years ago · Juan Pablo Isaza Report
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!