Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

335
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda