title: Setting a value to a input inside of var
body: <p>I'm curios is it possible to access and modify data inside of javascript var, so far i tried it with pure javascript as well as with jquery. So both versions are fine for me.</p>
  
  <pre><code>var data = {
      'name': 'Jhone',
      'category': 'Human',
      'type': 'good one',
  },
      form = `&lt;input type='text' name='name' id='name'&gt;
              &lt;input type='text' name='category' id='category'&gt;
              &lt;input type='text' name='type' id='type'&gt;`;
  </code></pre>
  
  <p>JQuery version (not working)</p>
  
  <pre><code>$.each(data, function( key, value ) {
  
      if ($.type(value) === 'string' &amp;&amp; value !== '')
          $(form).find('#'+key).val(value)
  });
  </code></pre>
  
  <p>JavaScript version (not working) (sorry don't know how to make foreach in pure js but the problem is with accessing element)</p>
  
  <pre><code>$.each(data, function( key, value ) {
  
      if ($.type(value) === 'string' &amp;&amp; value !== '')
          form.getElementById(key).value = value ;
  });
  </code></pre>
  
  <p>The main point is that i want to create js forms dynamically and avoid setting data like :</p>
  
  <pre><code>var form = `&lt;input type='text' name='name' id='name' value='`+ value +`'&gt;`;
  </code></pre>