-3
const shouldCancelExam = grades => {
    return grades.some(grade=>{grade>=18});
}

the above gives False for shouldCancelExam([10, 12, 10, 18])

However, the below is giving the correct output which is True. What is causing the difference?

const shouldCancelExam = grades => {
    return grades.some(grade=> grade>=18);
}
ugugugu
  • 3
  • 1

1 Answers1

1

Always remember that when you use arrow function and have a single statement you do not require {} if you using {} then you have to write return type keyword

    const shouldCancelExam = grades => {
            return grades.some(grade=> {
                             return grade>=18
    });
 }


const shouldCancelExam = grades => {
            return grades.some(grade=> grade>=18);
        }