Skip to content

Commit 45392ba

Browse files
author
Connor Leech
committed
add fizzbuzz
1 parent 6628ed5 commit 45392ba

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// --- Directions
2+
// Given an array and chunk size, divide the array into many subarrays
3+
// where each subarray is of length size
4+
// --- Examples
5+
// chunk([1, 2, 3, 4], 2) --> [[ 1, 2], [3, 4]]
6+
// chunk([1, 2, 3, 4, 5], 2) --> [[ 1, 2], [3, 4], [5]]
7+
// chunk([1, 2, 3, 4, 5, 6, 7, 8], 3) --> [[ 1, 2, 3], [4, 5, 6], [7, 8]]
8+
// chunk([1, 2, 3, 4, 5], 4) --> [[ 1, 2, 3, 4], [5]]
9+
// chunk([1, 2, 3, 4, 5], 10) --> [[ 1, 2, 3, 4, 5]]
10+
11+
function chunk(array, size) {
12+
13+
}
14+
15+
16+
console.log(chunk([1, 2, 3, 4], 2));
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// --- Directions
2+
// Write a program that console logs the numbers
3+
// from 1 to n. But for multiples of three print
4+
// “fizz” instead of the number and for the multiples
5+
// of five print “buzz”. For numbers which are multiples
6+
// of both three and five print “fizzbuzz”.
7+
// --- Example
8+
// fizzBuzz(5);
9+
// 1
10+
// 2
11+
// fizz
12+
// 4
13+
// buzz
14+
15+
16+
function fizzBuzz(integer){
17+
let output = '';
18+
for(var i = 1; i <= integer; i++){
19+
if(i % 3 === 0 && i % 5 === 0){
20+
output = "fizzbuzz";
21+
} else if (i % 3 === 0){
22+
output = "fizz";
23+
} else if (i % 5 === 0){
24+
output = "buzz";
25+
} else {
26+
output = i;
27+
}
28+
console.log(output);
29+
}
30+
}
31+
32+
fizzBuzz(15);

0 commit comments

Comments
 (0)