rtivital
1/21/2016 - 12:45 PM

anogram.js

function isAnagram(first, second) {
  var results = [];
  for (var ii = 0; ii < first.length; ii++) {
    var result = false;
    var letter = first[ii];
    for (var jj = 0; jj < second.length; jj++) {
      console.log(ii, jj, letter, second[jj]);
      if (letter === second[jj]) {
        result = true;
        break;
      }
    }
    
    results[ii] = result;
  }

  var end = true;
  for (var kk = 0; kk < results.length; kk++) {
    if (results[kk] === false) {
      end = false;
    }
  }

  return end;
}