Get _m_s time format from milliseconds value
Seems overly complicated.  Let the builtin math and parsing functions do the work for you.  And name time values something like t.



const ms = t =&gt; alert( `${parseInt( t/1000 / 60 )}m${parseInt( t/1000 % 60 )}s` )
ms(1040370);