Associative array/Iteration: Difference between revisions

Content deleted Content added
No edit summary
m minimal changes to fixed code so it works.
Line 544: Line 544:
myhash["!"] = 9;
myhash["!"] = 9;


var output, key;
var output = '', // initialise as string
key;
for (key in myhash) {
for (key in myhash) {
if (myhash.hasOwnProperty(key)) {
if (myhash.hasOwnProperty(key)) {
Line 560: Line 561:
myhash["!"] = 9;
myhash["!"] = 9;


var output, val;
var output = '', // initialise as string
val;
for each (val in myhash) {
for (val in myhash) {
if (myhash.hasOwnProperty(val)) {
if (myhash.hasOwnProperty(val)) {
output += "value is: " + val;
output += "myhash['" + val + "'] is: " + myhash[val];
output += "\n";
output += "\n";
}
}