I am trying to create a function which can check whether all the items in the list given are the same or not. But in the end it doesn't return anything but undefined. Please help. What am I doing wrong here.
function check(list) {
let number = 0;
if (number == list.length) {
return true;
} else {
for (let l = 0; l < list.length; l++) {
if (list[0] != list[l]) {
return false;
}
else {
number += 1
}
}
}
}