title: Is there a better and faster way to replace digits in string by the text in Javascript?
body: <p>I'd like to <strong>efficiently</strong> (one run over the string, not more) replace values of 1,2,3 in a string to their text representation, s.t. one, two, three. What would be the most efficient way in JS for that?</p>
  
  <p>Example:</p>
  
  <p><strong>Input</strong>: <code>Old value '2', new value: '1', predicted value: '3'</code></p>
  
  <p><strong>Output</strong>:  <code>Old value 'two', new value: 'one', predicted value: 'three'</code></p>
  
  <p>Here is the solution I came up with:</p>
  
  <pre><code>function formatActionInSysHistory(strValue) {
      let dict = {
        1: 'one',
        2: 'two',
        3: 'three'
      }
      foo = strValue.replace(/[123]/g, val =&gt; dict[val])
      console.log(foo)
  }
  formatActionInSysHistory("Old value '2', new value: '1', predicted value: '3'")
  </code></pre>