Show Buttons
Share On Facebook
Share On Twitter
Share On Google Plus
Share On Linkdin
Share On Reddit
Contact us
Hide Buttons

Determine if a number is Odd or not

Problem description :

Write a method to determine the given number is odd or not.
If it’s not a number then throw an error.
Add this method as native javascript method.

Input : A number

Output : Boolean

Logic :

  • Check the given argument is a number or not.
  • If its a number then divide the number by 2,
    • If the remainder is +1, -1 then return true.

Solution :

We can add this method as a native javascript method on the Number.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *