Maybe like this (it's no valid JS code for I am not a JS developer):
```
minutes = seconds / 60 (without rest)
secs = seconds - minutes * 60
if secs < 10  then add a leading 0
if minutes < 10 then add a leading 0
(optional: if minutes > 59 then do some more logic to add leading hour digits and to correct the minutes digits)
```