Data Tables in Functions?

#1

I have a coding question. I’m new to this and have searched for answers already myself. My student asked the following the other day:

“Why can’t I call or read records ( form a data table) in a function similar to how I can in events or separately?”

First of all, can she? If so, how? If not, why not?

PS-She has already found a workaround but wants to explore the logic behind why she can’t do it in javascript, if that is the case.

Thanks in advance!

James Hock
Denver, Colorado

#2

Hi @james.r.hock,

Welcome to the code.org forum!

I’m not sure I understand her question.

I tried putting a table “read” command in a function, and then have a button trigger a call to that function: https://studio.code.org/projects/applab/416l-umZLLM3Vt8U4YDEzw
Seems to work fine for me. Perhaps this isn’t what she means.

Would it be possible for your student to share her code (using the “share” button) of her original code that wasn’t working, and then we can take a closer look at what she was trying to do and better answer why it wasn’t working?

Frank

#3

Frank,

Thanks so much for your response. I have passed it on to Taylor. If she has further questions I’ll get back in touch with a snapshot of her code.

Cheers,

James