-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathFullCourseCode-Master.js
More file actions
58 lines (43 loc) · 1.28 KB
/
FullCourseCode-Master.js
File metadata and controls
58 lines (43 loc) · 1.28 KB
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
/**
* Created by jason.wollam on 6/17/2016.
*/
// FullCourseCode.js
var returnArrayFromCsvString = function(string){
return string.split(",")
}
var fizzBuzzMain = function(maxIterations){
var responseArray = [];
var iterations = (maxIterations == undefined)? 100 : maxIterations;
try{
for(var i = 0; i < iterations; i++){
responseArray.push(returnStringFizzBuzz(i));
}
//return responseArray;
}catch(ex){
throw ex
}
}
var returnStringFizzBuzz = function(intUnderTest){
var fizz = 3;
var buzz = 5;
if(isEvenlyDivisibleInteger(intUnderTest, fizz) && isEvenlyDivisibleInteger(intUnderTest, buzz)){
return "FizzBuzz";
}
if(isEvenlyDivisibleInteger(intUnderTest, fizz)){
return "Fizz";
}
if (isEvenlyDivisibleInteger(intUnderTest, buzz)){
return "Buzz";
}
return intUnderTest;
}
var isEvenlyDivisibleInteger = function(dividend, divisor){
var response = (!isNaN(dividend % divisor))? !(dividend % divisor) : undefined;
return response
}
module.exports = {
ReturnArrayFromCsvString : returnArrayFromCsvString,
FizzBuzzMain : fizzBuzzMain,
BoolCheckForEvenlyDivisibleInteger : isEvenlyDivisibleInteger,
ReturnStringFizzBuzz : returnStringFizzBuzz
}