{"ScriptPreparationCode":"dictionary = [\u0027hack\u0027, \u0027a\u0027, \u0027rank\u0027, \u0027khac\u0027, \u0027ackh\u0027, \u0027kran\u0027, \u0027rankhacker\u0027, \u0027a\u0027, \u0027ab\u0027, \u0027ba\u0027, \u0027stairs\u0027, \u0027raits\u0027]\r\nquery = [\u0022a\u0022, \u0022nark\u0022, \u0022bs\u0022, \u0022hack\u0022, \u0022stair\u0022]","TestCases":[{"Name":"reduce foreach filter","Code":"function name() {\r\n const sortedDictionary = dictionary.reduce((sorted, el) =\u003E {\r\n sorted.push(el.split(\u0027\u0027).sort().join(\u0027\u0027))\r\n return sorted\r\n }, [])\r\n\r\n let count = 0\r\n query.foreach(el =\u003E {\r\n sortedQuery = el.split(\u0027\u0027).sort().join(\u0027\u0027)\r\n count = sortedDictionary.filter(el =\u003E (el == sortedQuery).length)\r\n console.log(count)\r\n })\r\n}","IsDeferred":false},{"Name":"foreach foreach filter","Code":"function sorting(array) {\r\n let sortedArray = []\r\n array.forEach((el) =\u003E {\r\n sortedArray.push(el.split(\u0027\u0027).sort().join(\u0027\u0027))\r\n })\r\n return sortedArray\r\n}\r\n\r\nfunction stringAnagram(dictionary, query) {\r\n // Write your code here\r\n let sortedDictionary = sorting(dictionary) \r\n let sortedQuery = sorting(query) \r\n \r\n let count=0\r\n let counting=[]\r\n \r\n for (let i = 0; i \u003C sortedQuery.length; i\u002B\u002B) {\r\n count = sortedDictionary.filter((v) =\u003E (v === sortedQuery[i])).length;\r\n counting.push(count)\r\n }\r\n return counting\r\n}\r\n","IsDeferred":false}]}