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

338
Views
Uncaught ReferenceError: function is not defined error for 1 function

I think it's a very common problem but I've a code like this:

function add(num1, num2) {
  return num1 + num2;
}

function hello() {
  return "Hello";
}
window.alert("Num1 + Num2 = " + add(10, 5));

window.alert(hello());

The thing is, add() function works perfectly but try() is not. Why? I am working on Visual Studio Web Application.

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

0

Its becuase try is a reserved keyword in javascript as in try-catch, similarly you cannot use keywords like let, const, var, do, for ... etc as variable names or function declarations, change your function name to hello or something else and it should work perfectly fine

about 4 years ago · Juan Pablo Isaza Report

0

That's because try is a reserved word, have you ever seen

try {

}catch(e){}

So change the name of the function, simply use try1()

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!