title: Create curried functions by looping
body: <p>I would like to curry a function with different values from an object and save the created functions as object keys. The curried value gets overwritten while looping</p>
  
  <pre><code>function print (a,b){
      console.log(a + b)
  }
  
  var functions = {
      foo : "",
      bar : ""
  }
  
  for (var key in functions) {
  
      functions[key] = function(a){
          var val = key; // the problematic part saving the value
          return print(a,val)
      }
  
  }
  
  functions.foo('test-')
  functions.bar('test-')
  </code></pre>
  
  <p>output</p>
  
  <pre><code>&gt;&gt;&gt;test-bar
  &gt;&gt;&gt;test-bar
  </code></pre>
  
  <p>desired output</p>
  
  <pre><code> &gt;&gt;&gt;test-foo
   &gt;&gt;&gt;test-bar
  </code></pre>
  
  <p>im missing the idea on how to save the val variable for good and not overwriting it while looping</p>