I am attempting to implement a JavaScript function that checks for repeated letters within a string. The goal is for the function to return false if any repeating letters are found, and true if no repeats are present. However, I am encountering an issue where the function does not provide a return value as expected. Essentially, I aim to compare two strings and output a boolean result based on their content.
function isIsogram(str) {
let str1 = str.toLowerCase().split("");
//console.log(str.toLowerCase())
let str2 = []
for (let i = 0; i < str1.length; i++) {
//console.log(str1[i])
if (str2.indexOf(str1[i]) === -1) {
str2.push(str1[i])
}
}
//console.log(str2)
if (str2 === str1) {
return true;
} else return false;
}
console.log(isIsogram("abba"))