I was solving a problem on code wars in JS and I am failing all the tests and I can’t find where I’m going wrong.
There is also no instruction for special cases.
I think there could be an issue with the tests.
Below is the link to the kata and the code I wrote:
function openOrSenior(data) {
var result = []
for(var i = 0; i < data.length; i++) {
var r
if (data[i][0] >= 55 && data[i][1] > 7) { r = "Senior"; } else { r = "Open";}
if (data[i][1] > 26 || data[i][1] < -2) r= "Invalid Handicap";
if (data[i][0] === undefined && data[i][1] === undefined) r = [];
if (data[i][0] === undefined || data[i][1] === undefined) r = "Incomplete Data";
result.push(r)
}
console.log(result);
}
Also, is there a better/shorter way of writing the same code? I wrote an if/else if/else statement but it had some logic problem.