ES6 How to convert key, value pair to string recursively in javascript?
<p>I try to interpolate error messages, because I need it in a special text format.
Whats the best practice doing that nowadays :)
thanks for any help!</p>

<p><a href="http://codepen.io/radosch/pen/wWYPYG?editors=1111" rel="nofollow">http://codepen.io/radosch/pen/wWYPYG?editors=1111</a></p>

<p><strong>desired outcome:</strong></p>

<pre><code>Password longer then 5 chars \n
Email has invalid format \n
</code></pre>

<p><strong>Source:</strong></p>

<pre><code>let data = {
  "errors": [
    {
      "password": "must min have 5 characters"
    },
    {
      "email": "has invalid format"
    }
  ]
}
</code></pre>

<p><strong>possible solution:</strong></p>

<pre><code>let res = data.errors.map(function(error, index) {
  let keyName = Object.keys(error)
  let str = error[keyName]
  return keyName + " " + str ;
});

console.log(res.join("\n"));
</code></pre>