-
Notifications
You must be signed in to change notification settings - Fork 0
/
LetterCounter1.js
34 lines (30 loc) · 1.22 KB
/
LetterCounter1.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* eslint-disable max-len */
// Write a function that takes a string consisting of zero or more space separated words
// and returns an object that shows the number of words of different sizes.Words consist of any sequence of non-space characters.
const wordSizes = (inputString) => {
let output.create = {};
let outputArray = [[0], [0], [0], [0], [0], [0], [0], [0]];
let inputArray = [];
inputArray = inputString.split(' ');
console.log(inputArray);
inputArray.forEach(element => {
outputArray[element.length]++;
});
<<<<<<< HEAD
=======
let outputValues = [];
for (let index = 0; index < outputArray; index++) {
if outputValues[index[]]
}
>>>>>>> ae0152988cfadf4409974e98d47950f87a650547
console.log(outputArray);
console.log(output);
for (let index = 0; index < outputArray.length; index++) {
output.key = String(index)
output.value = outputArray[index];
};
};
wordSizes('Four score and seven.'); // { "3": 1, "4": 1, "5": 1, "6": 1 }
wordSizes('Hey diddle diddle, the cat and the fiddle!'); // { "3": 5, "6": 1, "7": 2 }
wordSizes("What's up doc?"); // { "2": 1, "4": 1, "6": 1 }
wordSizes(''); // {}