Access Json outside of javascript each function

Saturday, July 5, 2014

below is my script,

var holidays = {};
var count=0;
$('.row').each(function(index) {
var names = document.getElementById('name['+count+']').value;
var dates = document.getElementById('dateh['+count+']').value;
holidays[names] = dates;
count ++;

If i do console.log(holidays); inside the function i can get the json object, but if i do the same outside of $('.row').each(function(index) it's not printing any.

Did anyone know where i'm going wrong ?