I then Googled "applescript print to console" and got this: https://stackoverflow.com/questions/13653358/how-to-log-obje... ; admittedly this answer took a few minutes to read through, but the second most upvoted answer recommended using log, which your ChatGPT-developed solution (eventually) used.
Compare them to my original transcript. They don't provide me with enough information: how do I actually run that code?
I got ChatGPT to split me out a zsh script, which caused it to show me how to use "osascript -e ".