Skip to content

Instantly share code, notes, and snippets.

@ryanorsinger
Last active November 30, 2018 15:57
Show Gist options
  • Save ryanorsinger/680870a31175c3e413e00b7ce88e279e to your computer and use it in GitHub Desktop.
Save ryanorsinger/680870a31175c3e413e00b7ce88e279e to your computer and use it in GitHub Desktop.
array, loop, and function exercises
More practice w/ loops and arrays
Exercise 1:
Write a function named oneHundred() that returns an array with integers starting at 1 and ending at 100;
Exercise 2:
Write a function named reverse() that takes in an array and returns a reversed copy of the provided array. This function should not alter the orignal array sent into it.
Exercise 3:
Write a function named sumAll() that takes in an array of numbers and returns the sum of all the numbers. Use sumAll() on oneHundred() to get the sum of all numbers 1 + 2 + 3... + 100
Exercise 4:
Write a function named multiplyAll() that takes in an array of numbers and returns the product of all numbers. Use multiplyAll on oneOnehundred() to get the product of 1*2*3*...100
Exercise 5:
Write a program that computes the sum all of the odd numbers between 1 and 1000.
Exercise 6:
Write a program that computes the product of all integers divisible by 3 that are in-between 1 and 100.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment