anagram program in javascript

Solutions on MaxInterview for anagram program in javascript by the best coders in the world

showing results for - "anagram program in javascript"
Gianluca
07 Jan 2017
1    function group_anagrams(arr) {
2      let   sortedArr = arr.map(item => item.split('').sort().join(''));
3      let setArr = new Set(sortedArr);
4      let reducedObj = {};
5      for (let setItem of setArr) {
6        let indexArr = sortedArr.reduce((acc, cur, index) => {
7          if (setItem === cur) {
8            acc.push(index);
9          }
10          return acc;
11        }, []);
12        reducedObj[setItem] = indexArr;
13      }
14      let finalArr = [];
15      for (let reduceItem in reducedObj) {
16        finalArr.push(reducedObj[reduceItem].map(item => arr[item]));
17      }
18      return finalArr;
19    }
20    group_anagrams(['car','cra','rca', 'cheese','ab','ba']);
Tim
28 Sep 2018
1function anagram(name, words) {
2	var a = name.replace(/\s/g,'').toLowerCase().split('').sort().join('');
3	var b = words.join('').split('').sort().join('');
4	return a == b;
5}
Mariella
11 Apr 2018
1function isAnagram(stringA, stringB) {
2  // Sanitizing
3  stringA = stringA.toLowerCase().replace(/[\W_]+/g, "");
4  stringB = stringB.toLowerCase().replace(/[\W_]+/g, "");
5
6  // sorting
7  const stringASorted = stringA.split("").sort().join("");
8  const stringBSorted = stringB.split("").sort().join("");
9
10  return stringASorted === stringBSorted;
11}
Marius
22 Feb 2016
1function anagram(name, words) {
2	name =  name.toLowerCase().split('').sort().join('').trim();
3  words = words.join('').toLowerCase().split('').sort().join('');
4  return name === words;
5}
queries leading to this page
anagram check in pythonanagram interview questions javascriptjs anagram in stringspython check if anagramcheck if a string is anagramcheck anagramwhere my anagrams at javascriptanagrams string in javascriptjs is anagramanagramas javascriptangrams programing in javascriptanagram javscriptjavascript anagram functionvanilla javascript anagramjavascript function to detect anagram counts in string arrayanagram javascript examplenumerical anagrams jsjs find anagrams in a list of wordsjavascript find anagrams string javascript anagrammanagrams jsanagram js function arrayhow to find in an anagram in jsmake anagram javascriptanagram code in jswhat is anagram javascript string anagram in javascriptcheck anagram or not in javajava script anagramshow to make anagram javascript without built in functionanagrams in javascriptanagram 2 string javasvriptuse sets as anagrams jsarray indexof javascript return anagrammake anagram in jsanagram meaning jsalphabetic anagrams javascriptcounting anagram jshow to find anagram javascriptcheck for anagram in pythonanagram problem in javascriptanagram string in javascriptfirst anagram javascriptcheck anagram in javajava program to check for anagramanagram program javascripttwo words of anagrams programming in javascriptjavascript anagramhow to write an anagram function javascriptjavascript program to find string is anagram or notanangram javascriptall anagrams jscheck anagrams javascripthow to print anagrams in javascriptjavascript check for anagramanagram javascriptanagram algorithm jsanagram meaning in jsanagram foreach jshow to check anagram pythonjavascript anagrams functioncheck if anagramcheck anagram correctfinding out anagrams using jsanagram array javascript anagram javascriptcheck anagram in javascriptanagrams finder javascriptcheck if string is an anagramcheck anagram in pythonjavascript count anagram in arrayfind all anagram in an array javascriptjava program to check anagramall anagrams javascriptjavascript get anagrams stringanagram indexof javascriptanagram in javascriptfind all anagrams javascriptpython check anagramjavascript anagram most efficient waytjs anagramsanagram for arrays in javascript problemsanagrammes jscoding anagram solver javascripthow to check if a string is an anagram in pythonjavascript numbers anagramhow to check anagram in javascriptcheck string is anagram or notjavascript anagram two stringshow to check anagram javascriptfunction anagrams 28word words 29 javascriptanagram detection jsanagram javascript solutionhow to make anagrams of words in javascriptjavascript all anagrams solutionanagram checkanagram solution javascriptwhat is anagram in javascriptanagramm jsjavascript anagramsanagram program in jsjs find anagramfind anagrams of a string javascriptcheck anagram pythonwhere my anagrams at jsjavascript check if anagramanagram of a word javascript one lineanagram code in javascriptanagrams 2c javascriptanagram solver javascript number of arrangementsanagram in js 5dannagram jscounting anagrams javascripthow to check if a string is anagram of anotheranagrams algorithms jsanagrams o 28n 29 javascriptjavascript anagram checkjs is angramtwin word program in javascriptgenerate possible anagram jsanagrams javascript functioncheck for anagramis anagram javascriptmake an annagram javascript algorith 2cangrams javascriptvalid anagramcheck if strings are anagram of each otherfind anagram in javascript using flagsjs anagramhow many rearrangement to solve anagram javascriptanagram logic in javascriptanagrams o 28n 29 javascript without sortjavascript digit anagramspython check for anagramcheck anagrams in pythonanagram example in javascriptfind anagrams in list of strings jsanagram in the jsjavascript anagram solverhow to check anagram in a listanagram solver javascriptanagram js functiondetect anagrams in a sentence javascriptchecking anagrams in javaprogram for finding anagrams in javascriptcoding an anagram solver javascriptsimple program to find anagrams in javascriptanagrama javascriptjavascript code to check anagramhow to check if two string are anagramanagrams log 28n 29 javascriptjs string anagramanagrams in jsanagram in javascript problemsanagram injsgenerate anagrams javascriptanagram detector regexanagram function javascript anagram javascriptcheck if string are anagramjavascript count anagramscheck if strings are anagrams pythonanagrams javascriptcheck if anagram or notget array elements that are anagrams of each other javascriptanagram sets in javascriptanagram string program in javascriptanagram coding jsanagram algorithm javascriptfind anagrams javascriptanagram in javascript without es6how to find anagram in javascriptanagrams algorithm javascriptjavascript anagrams delete onetwo strings are anagrams in jsjs make anagramanagram js codeprint anagrams in a array of strings in jsjavascript anagram checkercheck if anagram javahow to do an anagram in javascriptanagram jsan anagrams of a string javascriptall anagrams of a string javascriptis anagram jsjavascript check arrays anagramsanagrams examples in javascriptjavascript find anagramsjavascript algorithm for detecting anagram in a stringhow to do anagrams in javascriptjavascript algorithm for detecting anagram in a sentencecreate an annagram from a string javascriptjavascript function to make anagramanagram program in javascriptjava check anagramjs all anagramsfirst anagram using index of javascriptanagrams finder javascript for a wordanagram count javascriptanagrams problem javascriptanagrams from a string javascripthow to write a javascript function that takes in an anagramcheck if string are anagram python fun with anagrams javascriptfind twin word jsjs anagram functionanagram using object javascriptremove anagrams from array javascriptanagram javasriptanagram program in javascrjavascript anagram programcheck if anagramm javascriptjavascript anagram checkanagrams code in javascript how to write anagram in javascriptanagrama function jsanagrams javascript true or falsecheck anagram python 3 22fun with anagrams 22 javascriptwrite the js program on anagramshow to find anagram using javascriptanagrama jsanagram array javascript solution es5anagram in jscheck if array has anagrams javascriptgenerate anagrams from input string javascriptanagram program in javascript regexhow to check string anagramsanagram js programreturn anagram javascriptpython anagram checkhow to generate different anagrams in javascript for a stringjavascript possible anagramscompare and remove anagrams jsvalid anagram javascriptanagrama em javascriptanagram with all the letters javascriptanagram using js setjavascript anagram listjavascript anagram most efficient wayanagram program in javascript