CC-05: For Loops and Conditionals 2

with Carmen Salas • 2024/10/09

Review

yesterday's CC starting from #5

Code Challenge

  1. Write a function multiplesOfSixAndNine that console logs all positive numbers from 1 to 100 inclusive if a number is a multiple of 6 and a multiple of 9.

const multiplesOfSixAndNine = () => {
  // can start at 6, increment by 3
  // because 6 and 9 is divisible by 3 anyway
  for (let i = 6; i <= 100; i+=3) {
    if (i%6==0 && i%9==0) {
      console.log(i);
    }
  }
}

// multiplesOfSixAndNine();
  1. Write a function named greaterNum that:

    • takes 2 arguments, both numbers.

    • returns whichever number is the greater (higher) number.

    • If both arguments are equal, it will return the string "both integers are equal"

    • If a given argument is not an integer data type it will return null

  1. Write a function named sumOfFourAndSix that returns the sum of all the multiples of 4 and 6 from 1 to 1000, including 1 and 1000.

  1. Write a function named oddAndEvenToN that takes in an integer argument and will console.log if a number is odd or even between 0 and the given arguement.

  1. Write a function named sumOfNotDivisibleByTen that returns the sum of all numbers 1 to 1000 inclusive, that are not divisible by ten.

  1. Write a function named greaterNum that:

    • takes 4 arguments.

    • returns whichever number is the greater (higher) number.

    • If two arguments are equal, it will return the string "two integers are equal"

    • If three arguments are equal, it will return the string "three integers are equal"

    • If all arguments are equal, it will return the string "all integers are equal"

    • If a given argument is not an integer data type it will return null

BONUS

  1. Write a function multiplesOfFourAndSix that returns an array of all positive numbers from 1 to 100 if that number is a multiple of 4 and a mutliple of 6.

  1. Write a function named countMultiplesOfTwo that takes in an array of integers and returns the number of integers in the array that are multiples of two.

Last updated