summary refs log tree commit diff stats
path: root/javascript/raindrops
diff options
context:
space:
mode:
authorAndinus <andinus@nand.sh>2021-09-05 16:38:00 +0530
committerAndinus <andinus@nand.sh>2021-09-05 16:38:00 +0530
commit46d81156b7bad4bef2f4443df6e9df4f03303c56 (patch)
tree0c5a96248f687426bff738f45a21b296fd1766ff /javascript/raindrops
parent52f2e1a8f60c3c1ef1569be89859e1a555fb740d (diff)
downloadexercism-46d81156b7bad4bef2f4443df6e9df4f03303c56.tar.gz
JS: Raindrops: Move rules to a const
Diffstat (limited to 'javascript/raindrops')
-rw-r--r--javascript/raindrops/raindrops.js18
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;
 };