I loop fine thru top level, then thru array that contains the objects, but can’t figure out how to get to the objects… (I have to get to each obj, then loop thru each one, yes? don’t know why I can’t figure this one out… have been struggling w/this one since last night…
so the string “Midnight’s Children” is passed into the function as the argument value. Then you’re calling $.each again to interate over value. As value is a string, it’s passing it into the function one character at a time, which is why you get the funky output.
Inside of function(j,value) the j variable is the property name and value is the string. So j is "title" and value is "Emma Bovary".
Or with the next property, j is "author" and value is "Gustave Flaubert"
So when value is "Emma Bovary", you are then using $.each() on that string, which goes ahead and processes that string character by character. As if it were an array consisting of [‘E’,‘m’,‘m’,‘a’,’ ',‘B’,‘o’,‘v’,‘a’,‘r’,‘y’]
You don’t want to process the strings as if they were an array. You have too many $.each command there. That’s why you’re getting your problem.
If you set a break point on the first $.each call and reload the page, the browser will pause the execution of the JS at that point and allow you to inspect the contents of the variables to see what’s going on.
I’m actually glad you’re mentioning this… I kept looking at the console and it showed no errors…
actually in Chrome I got “breakpoint is not defined…”
but I’ll figure it out… I’ll just read up on it more… I do need to learn more to debug JS with the browser dev tools (it’s great for markup and CSS, but I don’t know too much how to debug JS with those tools (except in obvious situations when you get errors, of course…)