Here is the code I am working with:
function likes(names) {
if (names.length == 0) {
return 'no one likes this';
} else if (names.length >= 4) {
return names[0]+ ', ' + names[1] + ' and' + names.length - 2 + 'others like this';
} else if (names.length <4 && names.length >0){
return names[0] + ', ' + names[1] +' and ' + names[2] +' like this'
}}
The issue I am facing is in line number 5. I am trying to subtract 2 from the length of the array and add it to the string, but my approach seems to be incorrect. If anyone has any suggestions on how to achieve this, your help would be greatly appreciated. Thank you!