JSFiddle - React, Tailwind, and code Playground

HTML

<input type="text" value="1234567" id="value" placeholder="Number">
<button id="convert">Convert</button>
Output: <p id="output"></p>

JavaScript

$('#convert').click(function(){
  var number = parseInt($('#value').val());
  var formatted = formatJapanese(number, 10);  
  $('#output').text(formatted);
});

$('#convert').click();

function formatJapanese(value, round) {
  var output = '';
  var symbols = [
    [ Math.pow(10, 16), '京' ],
    [ Math.pow(10, 12), '兆' ],
    [ Math.pow(10, 8), '億' ],
    [ Math.pow(10, 4), '万' ],
    [ Math.pow(10, 3), '千' ],
    [ Math.pow(10, 2), '百' ]
  ];
 
  for (var i = 0; i < symbols.length; i++) {
    var sym = symbols[i];

    if (value / sym[0] >= 1) {
      output = sym[1] + output;
      value /= sym[0];
    }
  }

  return (Math.round(value * round ) / round) + output;
}