letlikes=([a,b,...c])=>c.length>1?`${a}, ${b} and ${c.length} others like this`:c.length?`${a}, ${b} and ${c[0]} like this`:b?`${a} and ${b} like this`:a?`${a} likes this`:`no one likes this`;console.log(likes([]));// no one likes thisconsole.log(likes(["Peter"]));// Peter likes thisconsole.log(likes(["Jacob","Alex"]));// Jacob and Alex like thisconsole.log(likes(["Max","John","Mark"]));// Max, John and Mark like thisconsole.log(likes(["Alex","Jacob","Mark","Max"]));// Alex, Jacob and 2 others like this
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Discussion on: Daily Challenge #266 - Who Likes It?
For further actions, you may consider blocking this person and/or reporting abuse