This is trivial I know but I’m so used to OOP languages. I’m trying to figure out how to write out each name/value in either one alert or many, just so I can verify the data
var dCookieNameValuePairs = {};
for (i = 0; i < cookieValues.length; i++)
{
var akeyValuePair = aCookieValues[i].split("=");
dCookieNameValuePairs[keyValuePair[0]] = keyValuePair[1];
}
// display each name value pair testing
for (i = 0; i < dCookieNameValuePairs.length; i++)
{
alert("Name: " + dCookieNameValuePairs[] + "Value: " +
}
I’m stuck at the second for loop…I am not sure how to iterate through the dictionary and then focus on each name/value to spit it back.
You want to use
for..infor enumerating through a dictionary/map.I may have typo’d. Only use
.lengthwhen you are dealing with an array[]or a custom array-like object that you defined to have.lengthpopulated.