JSFiddle - React, Tailwind, and code Playground

JavaScript

function common_char(left, right) {
      var left_map = {};
      var right_map = {};
      var index = 0;
    
      while (index < left.length || index < right.length) {
    
        // Check left array
        if (index < left.length) {
          var c = left[index];
    
          if (!left_map[c]) {
            left_map[c] = true;
          }
    
          // Check if it exists in the other map
          if (right_map[c]) {
            return true;
          }
        }    
    
        // Check right array
        if (index < right.length) {
          var c = right[index];
    
          if (!right_map[c]) {
            right_map[c] = true;
          }
    
          // Check if it exists in the other map
          if (left_map[c]) {
            return true;
          }
        }    
        index++;
      }
      
      return false;
    }

alert(common_char('abc','defa'));