Steps to get the solution: 1. Take two objects existsStr1 and existsStr2 to store count of characters of two strings 2 .Loop over the characters of both the strings and keep the count in existsStr1 Object for first string and existsStr2 for second string. 3. Loop over existsStr1 using for in loop and check if the count of current character in existsStr1 and existsStr2 are same or not. 4. If the count of current character is not same, it means strings are not anagram of each other 5. If the count for all the characters in existsStr1 and existsStr2 is same, it means strings are anagram of each other. Code :

function anagram(str1, str2) {
  let existsStr1 = {};
  let existsStr2 ={};
  
  for(let i=0;i<str1.length;i++) {
    if(existsStr1[str1[i]]) {
	  existsStr1[str1[i]]++;
	} else {
	  existsStr1[str1[i]]=1;
	}
  }
  
  for(let i=0;i<str2.length;i++) {
    if(existsStr2[str2[i]]) {
	  existsStr2[str2[i]]++;
	} else {
	  existsStr2[str2[i]]=1;
	}
  }
  
  for(let key in existsStr1) {
    if(existsStr1[key] != existsStr2[key]) {
	  return false;
	}
  }
  return true;
}

let str1 = 'test'
let str2 = 'estt'
let result = anagram(str1, str2);
console.log('result', result); // true