I need to find the longest sub string within a string.
const string = "aassqwertybbvvqwertyuivv";
const a = string.split("").reduce((previousValue, currentValue, currentIndex, array) => {
let str = ""
if (previousValue !== currentValue) {
str = currentValue + str;
}
return str;
}, "");
console.log(a)
Here the answer shoule be 8 (qwertyui).
It just returns me the last string