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, |
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, |
var output = '', // initialise as string |
||
val; |
|||
for |
for (val in myhash) { |
||
if (myhash.hasOwnProperty(val)) { |
if (myhash.hasOwnProperty(val)) { |
||
output += " |
output += "myhash['" + val + "'] is: " + myhash[val]; |
||
output += "\n"; |
output += "\n"; |
||
} |
} |