JSFiddle - React, Tailwind, and code Playground
JavaScript
var superCounter = function(str) {
var counterObj = {};
counterObj.spaces = 0;
counterObj.words = str.split(' ').length;
counterObj.spaces = str.split('').filter(function(x){ return x==' '; }).length;
counterObj.chars = str.length;
return counterObj;
};
console.log(superCounter("Count me in"));