CC-05: For Loops and Conditionals 2
with Carmen Salas • 2024/10/09
Review
yesterday's CC starting from #5
Code Challenge
Write a function
multiplesOfSixAndNinethat 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();Write a function named
greaterNumthat: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
Write a function named
sumOfFourAndSixthat returns the sum of all the multiples of 4 and 6 from 1 to 1000, including 1 and 1000.
Write a function named
oddAndEvenToNthat takes in an integer argument and will console.log if a number is odd or even between 0 and the given arguement.
Write a function named
sumOfNotDivisibleByTenthat returns the sum of all numbers 1 to 1000 inclusive, that are not divisible by ten.
Write a function named
greaterNumthat: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
Write a function
multiplesOfFourAndSixthat returns an array of all positive numbers from 1 to 100 if that number is a multiple of 4 and a mutliple of 6.
Write a function named
countMultiplesOfTwothat takes in an array of integers and returns the number of integers in the array that are multiples of two.
Last updated