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

336
Visualizações
How do I deal with SyntaxError: Unexpected token: Typo

I want to know the logic of my error and how should I write it instead, please. Thank You

This is the question:

Write a function called "findShortestOfThreeWords". Given 3 strings, "findShortestOfThreeWords" returns the shortest of the given strings. If there are ties, it should return the first word in the parameters list.

The Error I get:

/home/runner/Module-1/index.js:21 }esle{ ^ SyntaxError: Unexpected token '{'

my code:

function findShortestOfThreeWords(word1, word2, word3){
  //if word1 was less than or equal word2
    //return word1
  //else
    //return word2
  //if word1 is less than or equal word3
    //return word1
  //esle 
    //return word3
  //if word2 is less than or equal word3
    //return word2
  //else
    //return word3

if(word1.length <= word2.length){
  return word1;
}else{
  return word2;
}if(word1.length <= word3.length){
  return word1;
}esle{
  return word3;
}if(word2.length <= word3.length ){
  return word2;
}else{
  return word3;
}
  
}

var output = findShortestOfThreeWords('a', 'two', 'three');
console.log(output); // --> 'a'
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Change esle to else

function findShortestOfThreeWords(word1, word2, word3){
  //if word1 was less than or equal word2
    //return word1
  //else
    //return word2
  //if word1 is less than or equal word3
    //return word1
  //esle 
    //return word3
  //if word2 is less than or equal word3
    //return word2
  //else
    //return word3

if(word1.length <= word2.length){
  return word1;
}else{
  return word2;
}if(word1.length <= word3.length){
  return word1;
}else{
  return word3;
}if(word2.length <= word3.length ){
  return word2;
}else{
  return word3;
}
  
}

var output = findShortestOfThreeWords('a', 'two', 'three');
console.log(output); // --> 'a'

about 4 years ago · Juan Pablo Isaza Relatório

0

it seems that there is a typo in your code: esle{ return word3;

try changing it to else

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