title: Create New Directory and Inserting Data in Firebase
body: <p>i want to create five new directories in Firebase dynamically. Also i want to insert data in those directories dynamically. I wrote this jquery script for that purpose.</p>
  
  <pre><code>for(var i=0; i&lt;5; i++) {
   var dataRef = new Firebase('https://blr-reaction-buttons.firebaseio.com/' + i);
   dataRef.on('value', function (snapshot) {
    var tempdata = snapshot.val();
    if (!tempdata) {
     tempdata=50;
     dataRef.set(tempdata);
    }
   });
  }
  </code></pre>
  
  <p>but instead of creating multiple directories, it just create one directory (in fact the last one) (pic below)...</p>
  
  <p><img src="https://i.stack.imgur.com/vyG3N.png" alt="generated directory of my firebase script"></p>
  
  <p>I just don't understand why this is happening. Pls help. Any kind of help would be appreciated. Thanks in advance.</p>