This works, but I don't understand why:
function hasUppercase(input) {
for (var i = 0; i < input.length; i++) {
if (input[i] === input[i].toUpperCase()) {
return true
} else {
return false
}
}
}
console.log(hasUppercase("no"));
console.log(hasUppercase("Yes"));
How come the 'true' for the 'Yes' beats all the falses?
returnstatement exits the function immediately.hasUppercase("ayyLmao")returns false.input[0]) you're testing for matches the case but take it off and you'll see for yourself