JSFiddle - React, Tailwind, and code Playground

JavaScript

//i want this output: 1,455,000
function num(val){
         var result = val.split('').reverse().join("")
                          .match(/[0-9]{1,3}/g).join(",")
                          .match(/./g).reverse().join("");
    return result     
}
    alert(num('1455000'))