isOdd or isEven?

PHOTO EMBED

Sat Aug 27 2022 15:27:27 GMT+0000 (Coordinated Universal Time)

Saved by @Carminos

// Step 1: Write a function declaration to calculate if a number is odd
function isOdd(number){
  if (number % 2 === 1) {
    console.log(`${number} is odd`)
  } else {
    console.log(`${number} is even`);
  }
}
isOdd(2)

// Step 2: Change it to an arrow function:
const isOdd = (number) => { 
  return number % 2 === 1 ? 
  console.log(`${number} is odd`) : 
  console.log(`${number} is even`)
};

isOdd(29);
content_copyCOPY