Math formula request

● ARCHIVED · READ-ONLY
Started by Monkey BizNiz 4 posts View original ↗
  1. Hey guys,

    I know this is for learning javascript, but since math is so closely tied to programming, i figured there might be a few math geniusses in here.

    im currently creating a time system, and im using functions to translate milliseconds to anything else. example:
    Code:
    _seconds: function() {
    return Math.floor(this._milliseconds/60)
    }

    Now as you may already have figured out, once milliseconds reaches 3600, the seconds isnt going back to 0, but keeps building up on 60.
    Now my question and request is; is there a smart math formula that can do this, and if so could you show it to me? Or, if theres a smarter alternative, I wouldnt mind knowing it either.
    Would greatly appreciate it, because ive kinda hit a roadblock. And the alternative as far as i know, would result in ugly code and alot of micromanaging.

    Thanks in advance,
  2. @?????? Oh thats helped a ton! I wasnt even aware of the existence of the modulus operator, this will be extremely useful in the future. exactly what I as looking for, thanks alot dude!
  3. np. happy to help :)

    Yea, the modulus is a very handy operator. Certainly one worth using where possible :D