title: Replace keys in string by value based on key–value entries in object
body: <p>I’m trying to convert each integer in a string to its corresponding value in an object based on its key–value entries. For example if I have:</p>
  <pre class="lang-js prettyprint-override"><code>var arr = {
      &quot;3&quot;: &quot;value_three&quot;,
      &quot;6&quot;: &quot;value_six&quot;,
      &quot;234&quot;: &quot;other_value&quot;
    };
  var str = &quot;I want value 3 here and value 234 here&quot;;
  </code></pre>
  <p>I would expext the output to be:</p>
  <pre class="lang-js prettyprint-override"><code>new_str = &quot;I want value_three here and value other_value here&quot;
  </code></pre>