Search⌘ K
AI Features

Challenge: Even or Odd?

Explore how to implement an asynchronous function in JavaScript that uses promises to determine if a number is even or odd. Learn to handle promise resolution and rejection based on input validation and timing, gaining hands-on experience with asynchronous callbacks and error handling.

Problem statement #

In this challenge, you have to implement the function evenOdd. It takes a number num as a parameter. You have to make use of the concept of promises to determine whether num is even or odd. You need to do the following:

  • If ...