Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function max(numbers) {
- let currentMax = numbers[0];
- for (let i = 0; i < numbers.length; i++) {
- if (numbers[i] > currentMax) {
- currentMax = numbers[i];
- }
- }
- return currentMax;
- }
- function min(numbers) {
- let currentMin = numbers[0];
- for (let i = 0; i < numbers.length; i++) {
- if (numbers[i] < currentMin) {
- currentMin = numbers[i];
- }
- }
- return currentMin;
- }
- function average(numbers) {
- let total = numbers[0];
- for (let i = 1; i < numbers.length; i++) {
- total += numbers[i];
- }
- return total / numbers.length;
- }
- function fizzBuzz(countTo) {
- const solution = [];
- for (let i = 1; i <= countTo; i++) {
- if (i % 15 === 0) {
- solution.push('fizzbuzz');
- } else if (i % 5 === 0) {
- solution.push('buzz');
- } else if (i % 3 === 0) {
- solution.push('fizz');
- } else {
- solution.push(i);
- }
- }
- return solution;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement