Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

anagram javascript

const isAnagram = (str1, str2) => {
	const str2Arr = str2.split('');
	for(let i = 0; i < str1.length; i++) {
		const index = str2Arr.indexOf(str1[i]);
		if(index === -1) return false;
   		str2Arr.splice(index, 1);
    }
	return !str2Arr.length;
}
console.log(isAnagram("abba","bbaa"))
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #anagram #javascript
ADD COMMENT
Topic
Name
1+1 =