Word Frequency Counter

EasyObject / Map

Description

Given a string `text`, return an object where keys are words and values are how many times each word appears. Words are case-insensitive and separated by spaces. Ignore punctuation (`.`, `,`, `!`, `?`).

Examples

Input: text = "hello world hello"

Output: { hello: 2, world: 1 }

Input: text = "The cat sat on the mat"

Output: { the: 2, cat: 1, sat: 1, on: 1, mat: 1 }

Constraints

  • •1 ≤ text.length ≤ 10⁴

Your Solution

JavaScript·4 test cases·Max 5,000 chars · 2s timeout · 10 runs/30s
Loading...