← Back to challenges

Bitwise Operator to Check Odd, Regular Expression to Check Even

JavaScriptHardconditionsregexbit_operationsvalidation

Instructions

Create two functions:

  1. The first is isOdd() to check if a given number is odd using bitwise operator.
  2. The second is isEven() to check if a given input is even using regular expressions.

Use of % operator is disallowed.

Examples

isOdd(3) ➞ "Yes"
// Use Bitwise Operator

isOdd(58) ➞ "No"
// Use Bitwise Operator

isEven("0") ➞ "Yes"
// Use Regular Expression

isEven("-99") ➞ "No"
// Use Regular Expression

Notes

  • Input will only be integers (positive/negative/zero).
  • For the second function, input will be numbers in string.
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.