jeudi 7 octobre 2021

Creating loops and adding else statement

Question 1: How do I add a else statement to this code with a string of 'what is this'?

let callback = (num) => {
  
    if (num % 2 == 0)
      return 'the number is even';
    else  {
      return 'the number is odd'}; 
  }
console.log(callback(2)); 

Question 2: How do create a loop that iterates from 0 to 10, and give the callback function the number the loop is currently on?

Note: Please see attached picture to get full instructions of code challenge for better understanding. instructions for challenge

Aucun commentaire:

Enregistrer un commentaire