JavaScript 把秒转换成分钟,比如100s转换成 01:40
Eaxmple
console.log(minSecond(3462));//57:42
console.log(minSecond(321));//05:21
console.log(minSecond(100));//01:40
console.log(minSecond(8562));//142:42
my answer
function minSecond(n) {
var second_ = Math.floor(n%60);
if (second_ < 10) {
second_ = '0'+ second_;
}
if (Math.floor(n / 60) < 10) {
var a = "0" + Math.floor(n / 60) + ':' + second_;
} else {
var a = Math.floor(n / 60) + ':' + second_;
}
return a;
}