// 3桁でカンマを挿入 function addFigure(num) { num = num + "" return num.replace(/(\d)(?=(\d\d\d)+$)/g, "$1,") }