js add comma number code example
Example 1: javascript format numbers with commas
function numberWithCommas(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
Example 2: javascript 1 + "1"
console.log(10+"1"); //101
console.log(10-"1"); //9
Example 3: javascript add text to li
let arr = ["g", "o", "o", "g", "L", "e";
let ul = document.getElementById("id_ul");
let i =0;
arr.map(arr=>{
var li = document.createElement("li");
ul.appendChild(li);
li.innerHTML = arr[i];
})