var lengthOfLongestSubstring = function(s) {
    let max = 0;
    let temp = 0;
    let duplicates = []
    for(let i = 0; i < s.length; i++){
        // if(i = s.length)
     if(!duplicates.includes(s[i])){
         temp += 1;
         duplicates.push(s[i]);
         if(max < temp ) max = temp;
        //  max = max < temp ? temp : max;
     }else{
         temp = 0;
     }
    }
    return max;
};


let a = "abcabcbb"

console.log(lengthOfLongestSubstring(a))