diff options
Diffstat (limited to 'javascript')
-rw-r--r-- | javascript/raindrops/raindrops.js | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/javascript/raindrops/raindrops.js b/javascript/raindrops/raindrops.js index 54696d3..c7614d5 100644 --- a/javascript/raindrops/raindrops.js +++ b/javascript/raindrops/raindrops.js @@ -1,17 +1,19 @@ 'use strict'; export const convert = (number) => { - let drops = ""; - - [ + const rules = [ {factor: 3, result: 'Pling'}, {factor: 5, result: 'Plang'}, {factor: 7, result: 'Plong'} - ].forEach(drop => { - if (number % drop.factor === 0) - drops += drop.result; - }); + ]; + + let drops = ""; + rules.forEach(drop => { + if (number % drop.factor === 0) + drops += drop.result; + }); - if (drops === "") drops += number; + if (drops === "") + drops += number; return drops; }; |