The function should return the length of the maximum substring in which there are no duplicate characters, but the program runs for an infinite amount of time
function findMaxLength(str) {
let right = 0;
let left = 0;
let answer = 0;
let arr = [];
while (right < str.length) {
let ch = str.split("")[right];
if (!arr.includes(ch)) {
arr.push(ch);
answer = Math.max(answer, (right - left + 1));
right++;
} else {
while (arr.includes(ch)) {
arr.splice(left, 1);
left++;
}
}
}
return answer;
}