JavaScript/6kyu/Who_likes_it.js
// For 4 or more names, the number in and 2 others simply increases.
For 4 or more names, the number in and 2 others simply increases.
For 4 or more names the number in and 2 others simply increases .
function likes(names) {
  let l = " like this"
  if (names.length === 0) {return "no one likes this"}
  if (names.length === 1) {return names[0] + " likes this"}
  if (names.length === 2) {return names[0] + " and " + names[1] + l}
  if (names.length === 3) {
    return names[0] + ", " + names[1] + " and " + names[2] + l;
  }
  if (names.length > 3) {
    return names[0] + ", " + names[1] + " and " +
    (names.length - 2).toString() + " others" + l
  }
}
function likes ( names ) { let l = " like this" if ( names . length === 0 ) { return "no one likes this" } if ( names . length === 1 ) { return names [ 0 ] + " likes this" } if ( names . length === 2 ) { return names [ 0 ] + " and " + names [ 1 ] + l } if ( names . length === 3 ) { return names [ 0 ] + ", " + names [ 1 ] + " and " + names [ 2 ] + l ; } if ( names . length > 3 ) { return names [ 0 ] + ", " + names [ 1 ] + " and " + ( names . length - 2 ) . toString ( ) + " others" + l } }
For 4 or more names, the number in and 2 others simply increases.
For 4 or more names the number in and 2 others simply increases .