Non-persistent storage for key-value pairs
You didn't say if you were able to use ES6 or not, but here's how I would do it if you can.  Note this solution ensures that you won't return or overwrite values that are on the Object prototype of the storage. It's also somewhat more terse, if you get rid of my comments.  

const storingFn = (function(){
  const store = {};

  return (key, value) =&gt; {
    // you only want to return things that are on 'store' not on its ancestral prototype. 
    if(store.hasOwnProperty(key)) {
      return store[key];
    }

    // If we get here, we know it's a set operation, so I'm assuming we need to quietly avoid setting null keys. Throw an error if you prefer. 
    if (value === 'undefined') {
      return null;
    }
    // I didn't test with &lt; ES6, as written it doesn't allow overwrite of 'toString' for example.  
    store[key] = value;
    return value;
  }
})();


EDIT: 

I also decided to actually return the value in the key, regardless of whether we are setting or getting, as your question didn't specify which was appropriate and I thought this gave a more consistent interface.

If you need to return false if the key is already set (right now it'll return the unchanged value) then that's a simple change to the first conditional block.