DEV Community

Discussion on: Daily Challenge #266 - Who Likes It?

jpantunes profile image
JP Antunes • Edited on

I think you don't need the break after the return, it would be unreachable.

const likes = (arr = []) => {
    switch (arr.length) {
        case 0:
            return "no one likes this";
        case 1:
            return `${arr[0]} likes this`;
        case 2:
            return `${arr[0]} and ${arr[1]} like this`;
        case 3:
            return `${arr[0]}, ${arr[1]} and ${arr[2]} like this`;
            return `${arr[0]}, ${arr[1]} and ${arr.length - 2} others like this`;