I hesitated to bring this question to StackOverflow because I'm not certain it's the type of thing the forum wishes to see. If not, just tell me so; I apologize in advance.
I have working code which I wanted to "elegantize" by moving some of the main inline code to a function and replacing it inline with a function call. But there's something wrong with the logic when I do. I've been messing with it for half a day and can't see it, though I'm sure it's something simple and stupid.
I've used screenshots instead of entering the code because the console log refers to line numbers which the screenshots show.
From the console log, it appears that, in the function, execution drops straight through to checkpoint 2 (line 48 of the modified code) leaving the dynamodb.scan statement (line 42) unexecuted and the var data (at line 52) undefined. It also appears that the function gets executed a second time because, after the logged 'undefined' error, execution somehow gets to checkpoint 0.5 (line 43).
This is a screenshot of the working code with the part I wanted to make a function outlined.
This is a screenshot of the modified code.
This is a screenshot of the console log.
Again, I apologize if this is an inappropriate question, but if a forum member can help, it would let a novice know what he's done wrong and would be greatly appreciated.