[word, freq]
. word
should be the lowercase version of the word and freq
the number denoting the count.
+The function should return an empty array, if no string is provided.
+The function should be case insensitive, for example, the strings "Hello" and "hello" should be treated the same.
+You can treat words that have special characters such as underscores, dashes, apostrophes, commas, etc., as distinct words.
+For example, given the string "Hello hello goodbye", your function should return [['hello', 2], ['goodbye', 1]]
.
+wordFrequency
should be a function.
+ testString: assert(typeof wordFrequency == 'function');
+ - text: wordFrequency
should return an array.
+ testString: assert(Array.isArray(wordFrequency("test")));
+ - text: wordFrequency("Hello hello world", 2)
should return [['hello', 2], ['world', 1]]
+ testString: assert.deepEqual(wordFrequency(example_1, 2), example_1_solution)
+ - text: wordFrequency("The quick brown fox jumped over the lazy dog", 1)
should return [['the', 2]]
+ testString: assert.deepEqual(wordFrequency(example_2, 1), example_2_solution)
+ - text: wordFrequency("Opensource opensource open-source open source", 1)
should return [['opensource', 2]]
+ testString: assert.deepEqual(wordFrequency(example_3, 1), example_3_solution)
+ - text: wordFrequency("Apple App apply aPP aPPlE", 3)
should return [['app', 2], ['apple', 2], ['apply', 1]]
or [['apple', 2], ['app', 2], ['apply', 1]]
+ testString: const arr = JSON.stringify(wordFrequency(example_4, 3)); assert(arr === example_4_solution_a || arr === example_4_solution_b)
+ - text: wordFrequency("c d a d c a b d d c", 4)
should return [['d', 4], ['c', 3], ['a', 2], ['b', 1]]
+ testString: assert.deepEqual(wordFrequency(example_5, 4), example_5_solution)
+ - text: wordFrequency("", 5)
should return []
+ testString: assert.deepEqual(wordFrequency(example_6, 5), example_6_solution)
+```
+
+