# JavaScript How to use NumberFormat in Javascript? numberformat javascript locale,number format javascript money,number format javascript

I'd like my countdown timer to show double digits, like "53:00" instead of "53:0". Not sure what's going wrong here? Thank you!

``````function convertSeconds(s) {
var min = Math.floor(s / 60);
var sec = s % 60;
return nf(min, 2) + ':' + nf(sec, 2);
}
``````

You can use `padStart()` to make sure a string is a certain length. If it's not it will pad it with whatever you want. In this case `0`:

``````const nf = (n, c) => n.toString().padStart(c, '0');

function convertSeconds(s) {
var min = Math.floor(s / 60);
var sec = (s % 60)
return nf(min, 2) + ':' + nf(sec, 2);
}

console.log(convertSeconds(64))
console.log(convertSeconds(119))``````

To pad zeroes you can do

``````function nf(num, places) {
var s = '0' + num;
return s.slice(places * -1);
}

function convertSeconds(s) {
var min = Math.floor(s / 60);
var sec = s % 60;
return nf(min, 2) + ':' + nf(sec, 2);
}
``````

Should get you what you want

If by `nf()` you mean a function that formats a `Number` as `string` of given digits, this can be an implementation of it:

``````function nf(number, digits) {
var res = number.toString();
while (res.length < digits) {
res = "0" + res;
}
return res;
}
``````

Demo:

``````function convertSeconds(s) {
var min = Math.floor(s / 60);
var sec = s % 60;
return nf(min, 2) + ':' + nf(sec, 2);
}

function nf(number, digits) {
var res = number.toString();
while (res.length < digits) {
res = "0" + res;
}
return res;
}

console.log(nf(4,2));``````

## Semantic UI: Collapsable sidebar with responsive content

I'm trying to create an admin template with a sidebar that can be toggled. I want it to just slide in and out and the content resize accordingly. I've tried everything I can think of and nothing works....

I'm trying to create an admin template with a sidebar that can be toggled. I want it to just slide in and out and the content resize accordingly. I've tried everything I can think of and nothing works....

1. semantic ui collapsible sidebar

I have a requirement to allow the user to download the multiple images by checking the file and clicking the button. For now I have provided a link below every image to download. But I need to do ...

I have a requirement to allow the user to download the multiple images by checking the file and clicking the button. For now I have provided a link below every image to download. But I need to do ...

1. make multiple image meme
2. make multiple bootable image file
3. how to make multiple image to pdf
4. how to make multiple image in photoshop
5. how to make multiple image slider
6. make one image from multiple images
7. image make multiple layers

## How to maintain same version for a library in a website with 20+ webpages

I'm using a third party JavaScript library in a website with 20+ HTML pages each with its own JavaScript and CSS file. But the problem is if a new version is available to the library then, I have to ...

I'm using a third party JavaScript library in a website with 20+ HTML pages each with its own JavaScript and CSS file. But the problem is if a new version is available to the library then, I have to ...

## bindTaskEvents function isn't called 2nd time

iam making a to do list app just using javascript... in which you can add tasks edit them and delete.but my edit task function is working for the list items with which are there in html document ...

iam making a to do list app just using javascript... in which you can add tasks edit them and delete.but my edit task function is working for the list items with which are there in html document ...

1