-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path3s-and-5s.js
65 lines (51 loc) · 1.29 KB
/
3s-and-5s.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
var test = require('mocha').it,
expect = require('chai').expect, // Use `expect(X).to.be` et al
assert = require('chai').assert; // OR use `assert.equal` etc
function threes(max){
var th = [];
for(var i = 3; i < max; i = i + 3) {
th.push(i);
}
return th;
};
function ten(){
return threes(10);
};
function twenty(){
return threes(20);
};
function fifty(){
return threes(50);
};
test('getting a list of multiples of 3', function () {
expect(ten()).to.deep.equal([3, 6, 9]);
expect(twenty()).to.deep.equal([3, 6, 9, 12, 15, 18]);
expect(fifty()).to.deep.equal([3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48]);
});
// END test 3s
function fives(max){
var fv = [];
for(var i = 5; i < max; i = i + 5) {
fv.push(i);
}
return fv;
};
function ten5(){
return fives(10);
};
function twenty5(){
return fives(20);
};
function fifty5(){
return fives(50);
};
test('getting a list of multiples of 5', function () {
expect(ten5()).to.deep.equal([5]);
expect(twenty5()).to.deep.equal([5, 10, 15]);
expect(fifty5()).to.deep.equal([5, 10, 15, 20, 25, 30, 35, 40, 45]);
});
function arrayAdd(fives(50), threes(50)) {
for (var i = 0; i< fv.length; i++){
sum.push(fv[] += th[]);
}
}