DEV Community


Discussion on: Daily Challenge #48 - Facebook Likes

chrisachard profile image
Chris Achard

JS, with each case defined. I went for straightforward, though there's probably room to condense this somehow given the repetition:

const likes = names => {
  switch(names.length) {
    case 0:
      return "no one likes this"
    case 1:
      return `${names[0]} likes this`
    case 2:
      return `${names[0]} and ${names[1]} like this`
    case 3:
      return `${names[0]}, ${names[1]} and ${names[2]} like this`
      return `${names[0]}, ${names[1]} and ${names.length - 2} others like this`
jasman7799 profile image
Jarod Smith

lol great minds think alike