In line 6 you are adding the array
marks to the number
sum. That doesn’t make much sense and you end up with
sum being a string that is greater than all the numbers you compare it to.
And keep an eye on indentation to make clear that sum is calculated inside the
for (let mark of marks) sum += mark;
thank you for the help
a is not in any condition statement, so it will be always be executed
That’s just wrong. There are four conditional
returns above it so it will only be executed if all four conditions are false.
You could have used else return a;
Of course but why should we add unnecessary code that doesn’t change the outcome?
I don’t know how to convince you but it’s not unnecessary. Just use “else return ‘a’;”
Adding the ‘else’ will work but it’s not needed.
If the 4 if statements are false ‘return a’ is always executed.
Yeah, I now get it, you’re right