function hydrate(s) { let waterCount = s.split('').filter(e => e.match(/d/)).reduce((acc, val) => +acc + +val, 0); return waterCount > 1 ? `${waterCount} glasses of water`: `${waterCount} glass of water`; }