/cc-02-for-loops-raylu511

cc-02-for-loops-raylu511 created by GitHub Classroom

Primary LanguageJavaScriptGNU General Public License v3.0GPL-3.0

Code Challenge: For Loops

Instructions

  1. Clone down this assignment to your `code-challenges' directory in AWS Cloud9.
  2. Code your solution using JavaScript in index.js.
  3. Be sure to run and test your code throughly!
  4. By the end of Code Challenge, commit and push your changes up to Github.
  5. Using the browser, verify that your solution is in your remote repo on Github.

Code Problems

  1. Write a function named countToTen that console.logs all the integers from 1 to 10.

  2. Write a function named countFromOne that takes in an integer argument, and console.logs all the integers from 1 up to the given integer.

  3. Write a function named countEveryEven that takes in an integer argument, and console.logs all the even integers from 1 up to the given integer, including the given integer.

countEveryEven(10) // logs 2 4 6 8 10
  1. Write a function named countEveryOdd that takes in an integer argument, and console.logs all the odd integers from 1 up to the given integer, including the given integer.
countEveryOdd(10) // logs 1 3 5 7 9

Bonus

  1. Write a fucntion named countEvens that takes in an array of integers and returns the number of integers in the array that are even numbers.
countEven([1,2,3,4,5,6,7,8,9,12]) // returns 5
countEven([1,2,22,204]) // returns 3
countEven([1,3,7,17,19]) // returns 0