Read a number, such as 521, change this number to 0521, and put it into four div, how to achieve?

read a number, such as 521

change this number to 0521

but put it into four div separately, how to realize it?

0 < / div >
5 < / div >
2 < / div >
1 < / div >

Feb.26,2021

let n = 521; //
n = (n*1).toString().padLeft(4,'0');
for(let v of n){
  let dom = document.createElement('div');
  dom.innerText = v;
  //dom appendTodom
}
Menu