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

344
Views
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 answers
Answer question

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 Report

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 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!