Skip to content

Latest commit

 

History

History
33 lines (24 loc) · 2.31 KB

File metadata and controls

33 lines (24 loc) · 2.31 KB

Anagrams easy #javascrip #arrays #blind75

by Pawan Kumar @jsartisan

Take the Challenge

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:

  • Both s and t consist of lowercase English letters.

Requirements:

  1. The function should take two arguments:
    • A string s.
    • A string t.
  2. The function should return:
    • 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

Back Share your Solutions Check out Solutions