Skip to content

Commit 83e216f

Browse files
author
wakidurrahman
committed
feat: update
1 parent a18e25b commit 83e216f

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/code-challenges/code-challenges-003-010.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,22 @@ multiDimensionalSumOfSeveralArrayVariationReduce([[3, 2], [1], [4, 12]]);
4949
* Your goal is to print all numbers between low and high, and for each of these numbers print whether or not the number is divisible by 3.
5050
* If the number is divisible by 3, print the word "div3" directly after the number.
5151
*/
52+
53+
function testDivisors(low, high) {
54+
// we'll store all numbers and strings within an array
55+
// instead of printing directly to the console.
56+
let output = [];
57+
58+
for (let i = low; i <= high; i++) {
59+
// simply store the current number in the output array
60+
output.push(i);
61+
62+
// Check if the current number is evenly divisible by 3
63+
if (i % 3 === 0) output.push('div3');
64+
}
65+
66+
// return all numbers and strings.
67+
return output;
68+
}
69+
70+
testDivisors(2, 10);

0 commit comments

Comments
 (0)