f([])"no one likes this"f(["Peter"])"Peter likes this"f(["Jacob","Alex"])"Jacob and Alex like this"f(["Max","John","Mark"])"Max, John and Mark like this"f(["Alex","Jacob","Mark","Max"])"Alex, Jacob and 2 others like this"
Basically, with a bit of wibbly wobbly trickery, depending on the input length, we either call the format function with ["no one"], the complete input, or the two first elements followed by the remaining quantity of items. Finally, we add (or not) an s to the like, and return the built string!
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.
And a bit of golf with the Intl.ListFormat tool!
Here is the output:
Basically, with a bit of wibbly wobbly trickery, depending on the input length, we either call the
format
function with["no one"]
, the complete input, or the two first elements followed by the remaining quantity of items. Finally, we add (or not) ans
to thelike
, and return the built string!