← Back to challenges

Both Zero, Negative or Positive

JavaScriptHardnumbersmathvalidationconditions

Instructions

Write a function that returns true if both numbers are:

  • Smaller than 0, OR ...
  • Greater than 0, OR ...
  • Exactly 0

Otherwise, return false.

Examples

both(6, 2) ➞ true

both(0, 0) ➞ true

both(-1, 2) ➞ false

both(0, 2) ➞ false

Notes

Inputs will always be two numbers.

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Remove Null from an Array