← Back to challenges

Ones, Threes and Nines (Version #1)

JavaScriptHardclassesnumbersmath

Instructions

Given an int, figure out how many ones, threes and nines you could fit into the number. You must create a class. You will make variables (class.ones, class.threes, class.nines) to do this.

Examples

let n1 = new OnesThreesNines(5)
n1.nines ➞ 0

n1.ones ➞ 5

n1.threes ➞ 1

Notes.

  • This was originally a Python problem over here.
  • See another Python version of this series.
  • I'd suggest using getters and setters for this, but you're welcome to use any method you choose!
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Barbecue Skewers