diff --git a/Exercises/4-count-types.js b/Exercises/4-count-types.js index 4c9545a..9247205 100644 --- a/Exercises/4-count-types.js +++ b/Exercises/4-count-types.js @@ -1,5 +1,13 @@ 'use strict'; -const countTypesInArray = null; + +const countTypesInArray = arr => { + const obj = {}; + for (const item of arr) { + const type = typeof item; + type in obj ? obj[type]++ : obj[type] = 1; + } + return obj; +}; module.exports = { countTypesInArray };