Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

341
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda