Skip to content

Instantly share code, notes, and snippets.

@peterfschaadt
Last active August 29, 2015 14:08
Show Gist options
  • Select an option

  • Save peterfschaadt/367ff8651f15c58e7358 to your computer and use it in GitHub Desktop.

Select an option

Save peterfschaadt/367ff8651f15c58e7358 to your computer and use it in GitHub Desktop.
1. Create a function with a loop that prints out only the odd positioned elements of an array that it takes in.
2. Create a function with a loop that prints out only the even numbers of an array that consists of only numbers.
3. Create a function that takes in two arguments, one is an array and one is a string. The function should loop through the array and return true for each time that the string matches the element the function is looping through.
4. Use JavaScript's random function inside a while loop to run the loop as long as your variable doesn't equal exactly 50. Limit your random sample to 1-100. Each time the loop runs, print something like this to the console: console.log(runValue + " doesn't equal 50, Run #" + runNumber).
Hints:
- You'll have to increment
- Math.random() - http://www.w3schools.com/jsref/jsref_random.asp
- You may have to round with Math.floor()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment