CC-04: For Loops and Conditionals
with Carmen Salas • 2024/10/08
Review
yesterday's CC
Code Challenge
Write a function named
countFromOnethat takes in an integer argument, and console.logs all the integers from 1 up to the given integer.
const countFromOne = (x) => {
for (let i = 1; i <= x; i++) {
console.log(i)
}
}
// tests
// countFromOne(10);
// countFromOne(1);Write a function named
countEveryOddthat takes in an integer argument, and console.logs all the odd integers from 1 up to the given integer, including the given integer.
Write a function
isNegativethat takes in a number parameter and returns true if the number is a negative value and false if the number is a positive value.
Write a function named
betweenFiveAndTwentythat takes in an integer parameter, and checks whether a given integer is within 5 and 20. It returnstrueif it is andfalseif not.
Write a function named
sumOfThreeOrFivethat returns the sum of all the multiples of 3 or multiples of 5 from 1 to 1000, exclusive.
Write a function named
isAllLowerCasethat takes in a string parameter, and returns true or false if the string consists of only lowercase letters.
BONUS
Write a function named
countMultiplesOfFivethat takes in an array of integers and returns the number of integers in the array that are multiples of five.
Last updated