JavaScript
This is the function which will give the output "true"if there is a repeated character in a string,,
otherwise it will give output "false"
function repeatChar(str) {
for (let char of str.toLowerCase()) {
if (str.indexOf(char) !== str.lastIndexOf(char)) {
return true;
}
}
return false;
}
console.log(repeatChar('aA')); //expected output "true" but here output is "false"... Why??