{"id":8506,"date":"2021-08-12T08:47:32","date_gmt":"2021-08-12T05:47:32","guid":{"rendered":"https:\/\/elzero.org\/?p=8506"},"modified":"2022-08-07T07:06:14","modified_gmt":"2022-08-07T04:06:14","slug":"javascript-problems-solving-add-commas-and-underscores","status":"publish","type":"post","link":"https:\/\/elzero.org\/old\/javascript-problems-solving-add-commas-and-underscores\/","title":{"rendered":"Add Commas And Underscores To Number"},"content":{"rendered":"<h3>\u0627\u0644\u062d\u0644<\/h3>\r\n\r\n<script type=\"text\/plain\" class=\"language-javascript\">\r\nfunction addCommasAndUnderscore(num) {\r\n  \/\/ Convert To String\r\n  let result = num.toLocaleString(); \/\/ Try Another Solution With RegExp\r\n  \/\/ Convert To Array\r\n  result = result.split(\"\");\r\n  \/\/ Update The Last Comma Value\r\n  result[result.length - 4] = \"_\";\r\n  \/\/ Convert To String\r\n  result = result.join(\"\");\r\n  return result;\r\n}\r\n\r\nconsole.log(addCommasAndUnderscore(120)); \/\/ 120\r\nconsole.log(addCommasAndUnderscore(1530)); \/\/ 1_530\r\nconsole.log(addCommasAndUnderscore(120510650)); \/\/ 120,510_650\r\nconsole.log(addCommasAndUnderscore(510650480910)); \/\/ 510,650,780_910\r\nconsole.log(addCommasAndUnderscore(12069057014032)); \/\/ 12,069,057,014_032\r\n<\/script>","protected":false},"excerpt":{"rendered":"<p>Add Commas And Underscores To Number With JavaScript<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1337],"tags":[],"class_list":["post-8506","post","type-post","status-publish","format-standard","hentry","category-problems-solving"],"_links":{"self":[{"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/posts\/8506","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/comments?post=8506"}],"version-history":[{"count":6,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/posts\/8506\/revisions"}],"predecessor-version":[{"id":8592,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/posts\/8506\/revisions\/8592"}],"wp:attachment":[{"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/media?parent=8506"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/categories?post=8506"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/elzero.org\/old\/wp-json\/wp\/v2\/tags?post=8506"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}