Create a function that accepts two string parameters s
and t
. The function should output true
when the strings are anagrams of one another, and false
if they're not.
Two strings are considered anagrams if you can shuffle the letters of one to create the other. For instance, "listen" and "silent" are anagrams because they use exactly the same letters the same number of times, just arranged differently.
Constraints:
s
and t
consist of lowercase English letters.Requirements:
s
.t
.true
if s
and t
are anagrams.false
otherwise.Example Usage:
// Example 1 const s1 = "racecar"; const t1 = "carrace"; console.log(areAnagrams(s1, t1)); // Output: true // Example 2 const s2 = "jar"; const t2 = "jam"; console.log(areAnagrams(s2, t2)); // Output: false