← Back to challenges

Is It the Same Upside Down?

JavaScriptHardstringssortingnumbersvalidation

Instructions

The number 6090609 has a special property: if you turn the number upside down (imagine rotating your screen 180 degrees), you get 6090609 again.

Write a function that takes a string on the digits 0, 6, 9 and returns true if the number is the same upside down or false otherwise.

Examples

sameUpsidedown("6090609") ➞ true

sameUpsidedown("9669") ➞ false
// Becomes 6996 when upside down.

sameUpsidedown("69069069") ➞ true

Notes

N/A

javascript
Loading editor…
⌘ ↡ to run
Walks through the solution with reasoning and edge cases.
Next: Shopping for Memorial Day! β†’