title: Given a string s, find the length of the longest substring without repeating characters
body: <p>Example  Input: s = &quot;abcabcbb&quot; Output: 3 Explanation: The answer is &quot;abc&quot;, with the length of 3. I tried writing this but if condition is never being exceuted. I am not able to figure out the reason.</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var lengthOfLongestSubstring = function(s) {
   let set = new Set();
      let c =0;
      for(let i =0; i&lt; s.length; i++){
          if(set.has(s[i])){
              set.size =0;
          }
          else {
              console.log(c)
              c++;
          }
      }
      return c;
  }; 
  console.log(lengthOfLongestSubstring("abcabcbb"))</code></pre>
  </div>
  </div>
  </p>