Answers for "given two strings return true if they are anagrams of one another in javascript"

0

given two strings return true if they are anagrams of one another in javascript

function anagrams(a, b) {
  let i = 0
  let sumA = 0
  let sumB = 0
  a = a.replace(/[\W]/g, "").toLowerCase()
  b = b.replace(/[\W]/g, "").toLowerCase()
  if (a.length !== b.length) return false
  !(function sumCharCode() {
    if (i < a.length) {
      sumA += a.charCodeAt(i)
      sumB += b.charCodeAt(i)
      i++
      sumCharCode()
    }
  })()
  return sumA === sumB;
}

console.log(anagrams("listen", "silent"))
Posted by: Guest on March-25-2021

Code answers related to "given two strings return true if they are anagrams of one another in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language