Who likes it? Problem ;_;

Who likes it? Problem ;_;
0.0 0

#1

Tell us what’s happening:

Help me with this codewars problem ;_; I keep getting the following

image

Your code so far

let array1 = [‘Alex’, ‘Jacob’, ‘Mark’, ‘Max’]

function likes (names) {
if (names===0)
{
return(“noone likes this”);
}

if (names===1)
{
return(names[0]+", like this");
}
if (names===2)
{
return(names[0]+" and “+names[1]+” like this");
}
if (names===3)
{
return(name[0]+", “+names[1]+”, and “+names[2]+” like this");
}
if (names > 3)
{
return (names[0]+", “+names[1]+”, “+ names[2]+” and “+ names.length-3+ " others like this”);
}

}
console.log(array1);
console.log(likes(array1));

// Your code above this line

Link to the challenge:
https://www.codewars.com/kata/5266876b8f4bf2da9b000362/train/javascript


#2

You’re comparing names (the array) with numbers. Maybe you meant comparing the array’s length?


#3

function likes(names) {
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]+” like this");
}
if (names.length===3)
{
return(name[0]+"," + names[1]+ “, and " +names[2]+ " like this”);
}
if (names.length > 3)

{
return (names[0]+", “+names[1]+”, "+ names[2]+ "and “+ names.length-3+ " others like this”);
}

}

names= [‘Alex’, ‘Jacob’, ‘Mark’, ‘Max’]

likes(names)