repl.it
@jffrydsr/

standupChallenge

Nodejs

No description

fork
loading
Files
  • index.js
  • problem.md
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
function multipleSum_with_Array(number) {
  let answer = []
  for (let i = 1; i < number; i++) {
    if ((i % 3 === 0) || (i % 5 === 0)) {
      answer.push(i);
    }
  }

  let sum = answer.reduce(function(a, b) {
    return a + b;
  });

  sum_type = typeof sum;
  sum_format = "Array method: " + String(sum) + "\n" + sum_type

  console.log(sum_format)
  console.log("-------------------------------------")

  return sum_format
}

function multipleSum_with_Incrementer(number) {

  let sum = 0;
  for (let j = 1; j < number; j++) {
    if (j % 3 === 0 || j % 5 === 0) {
      sum += j
    }
  }

  sum_type = typeof sum;
  sum_format = "Incrementer method: " + String(sum) + "\n" + sum_type

  console.log(sum_format)
  console.log("-------------------------------------")
  return sum_format;
}

multipleSum_with_Array(1000)
multipleSum_with_Incrementer(1000)
Fetching token
?