01-2 : Who likes it?

Strings

Solution

function likes(names) {
  if (names.length >= 4){
    return `${names[0]}, ${names[1]} and ${names.length - 2} others like this`;
  }
  else if (names.length === 0){
    return "no one likes this"
  }
  else if (names.length === 1){
    return `${names[0]} likes this`;
  }
  else if (names.length === 2){
    return `${names[0]} and ${names[1]} like this`;
  }
  else{
    return `${names[0]}, ${names[1]} and ${names[2]} like this`
  }
}

Here we are checking the various cases and are returning strings, using template literals, that include the names required for each condition per the problem statement.