No internet connection
  1. Home
  2. How to

New incredibly helpful resource for learning javascript - OpenAI ChatGPT

By Tristan Hoogland @Tristan
    2022-12-09 17:00:16.409Z

    For anyone looking to upskill their javascript chops and feeling a little overwhelmed with how to use certain methods or functions I'd highly recommend everyone consider checking out OpenAI's chatGPT. I'm not sure where anyone stands on that stuff, but wow this is wild.

    You can literally type in anything and it'll literally type back to you some kind of a solution that so far in my experience has been staggeringly accurate. You can even ask it to go over snippets of code for you and it'll give you feedback on errors its finding or ways you could improve it etc. This is all happening in realtime just as if you were chatting to someone.

    • 16 replies

    There are 16 replies. Estimated reading time: 12 minutes

    1. Damn that's scary.
      I gave it a chunk of code to refactor and it made some pretty solid suggestions.

      1. It even generated comments! 🤯

        1. TTristan Hoogland @Tristan
            2022-12-09 18:47:44.716Z

            man, ain't it wild?!

            I literally made so much progress on a few scripts within a few hours yesterday. Initially I thought I'd be like "eurgh, but I won't be learning by doing it this way", but so far it's been the opposite - because you provide it with unique examples everytime and it explains each step and why quite succinctly. It's helped me better understand certain methods and functions than digging around stackoverflow for hours...

        2. In reply toTristan⬆:
          Kitch Membery @Kitch2022-12-09 18:52:14.415Z

          Yeah man this is a great tool :-)

          Just refactored an old script as a test. It made a few small errors but overall it provided some great feedback!

          1. It's blowing my mind.
            I love how it's converting my if statements to && statements - something I could never really wrap my head around completely. It explains things pretty clearly.

          2. In reply toTristan⬆:
            samuel henriques @samuel_henriques
              2022-12-09 19:46:45.469Z

              🤯

              1. In reply toTristan⬆:
                Brenden @nednednerb
                  2022-12-09 22:04:36.378Z2022-12-09 22:51:51.310Z

                  I'm reading some of the notes on their design workflow... This is cool! AI is becoming very interesting. Artificial systems of real language-trained language models--whaddasay?

                  The part I'm growing skeptical about, though, is the word artificial.

                  I want to ask it if there is a better way to express

                  daaaaaaaaaaaaamn
                  

                  edit: Instead, I gave it an example of a script I wrote. I asked it to parse and explain what it was for. It gave very good answers and knew I was using Pro Tools—wow! After that, in the same "thread," I asked some general questions about Javascript notation, and it explained the concepts directly using my provided code as the example or context. Very cool.

                  1. In reply toTristan⬆:

                    minding blowing!! WoW

                    1. In reply toTristan⬆:
                      Dustin Harris @Dustin_Harris
                        2023-01-06 20:33:32.163Z

                        Just for 'fun' I showed a friend ChatGPT and how it can refactor code. I then asked it to write a poem about the function I gave it... and it did:

                        /**
                        * @param {PxTimecodeDisplay} rawTc
                        */
                        function formatTC(rawTc) {
                            let addZerosToSingleDigits = (value) => { return (String(value).length === 1) ? String(`0${value}`) : String(value); }
                            let tcArray = Object.values(rawTc); // object of HH, MM, SS, FF
                            tcArray = tcArray.map(addZerosToSingleDigits);
                            return tcArray.join(':')
                        }
                        

                        Here is a poem about the code you provided:

                        A function called formatTC
                        Takes in a timecode display
                        An object with hours, minutes, seconds, and frames
                        rawTC is its name, the parameter it claims

                        A little arrow function comes into play
                        addZerosToSingleDigits is what it's called
                        It takes a value, a number, small or tall
                        And adds a zero, if its length is just one digit, after all

                        The object's values are extracted and placed
                        Into an array, tcArray is its name
                        The arrow function is then used to give each a little grace
                        And add a zero, if needed, to avoid any shame

                        The array is mapped, the values all transform
                        Into strings, with zeros in front of single digits, as desired
                        The strings are joined, with colons as the norm
                        And the final result is returned, to be admired

                        A simple function, yet it serves its purpose well
                        Formatting timecodes, with zeros to ensure they look swell

                        1. Brenden @nednednerb
                            2023-01-06 20:49:00.300Z

                            I like that more than anything I've read by Shakespeare!

                            This poem is more relatable in 2023. Haha!

                          • In reply toTristan⬆:

                            man GPT is just scary:
                            Me:
                            write a javascript object that contains the first names and instruments of the member of the beatles
                            GPT:

                            var beatles = {
                                "John": "Guitar",
                                "Paul": "Bass",
                                "George": "Guitar",
                                "Ringo": "Drums"
                            };
                            

                            Me: also include the names of their wives
                            GPT:

                            var beatles = {
                                "John": {
                                    "instrument": "Guitar",
                                    "wife": "Yoko Ono"
                                },
                                "Paul": {
                                    "instrument": "Bass",
                                    "wife": "Linda McCartney"
                                },
                                "George": {
                                    "instrument": "Guitar",
                                    "wife": "Patricia Anne Boyd"
                                },
                                "Ringo": {
                                    "instrument": "Drums",
                                    "wife": "Maureen Cox"
                                }
                            };
                            

                            Me:
                            using the same object , write a script that will introduce the members to their wives

                            for (const [key, value] of Object.entries(beatles)) {
                                console.log(`Hello, my name is ${key} and I play the ${value.instrument}. Nice to meet you ${value.wife}`);
                            }
                            

                            GPT:
                            "This script will iterate through the beatles object and for each element, it will print a sentence introducing the member and his instrument to his wife."


                            Me: using the same object write a script for Pro Tools that will name the tracks using the band members and their instrument

                            GPT:
                            I'm sorry, I'm unable to write script for specific software like Pro Tools. However, I can give you a general idea of how to use the beatles object to name tracks using band members and their instruments.

                            GPT:

                            let trackNumber = 1;
                            for (const [key, value] of Object.entries(beatles)) {
                                console.log(`Track ${trackNumber}: ${key} - ${value.instrument}`);
                                trackNumber++;
                            }
                            

                            GPT:
                            "This script will iterate through the beatles object and for each element, it will print the track number and a string naming the track by the band member and their instrument. The variable trackNumber is used to keep track of the current track number and it will increment by 1 for each iteration.

                            Please note that this script is just an idea and it's not specific to Pro Tools, you may need to adapt it to match the way you want to name the tracks in Pro Tools or the way the application expects the inputs."
                            🤯🤯🤯

                            1. It's cray how it understands natural language questions and can use that to update previous responses…

                              1. TTristan Hoogland @Tristan
                                  2023-01-13 16:42:16.471Z

                                  HAHA. That's insane dude.

                                  I think while some of the results vary, it's generally quite attune to what you're wanting to achieve. I think the key is to know how to prompt it correctly, which I guess you could say is no different to anyone asking a question here!

                                  I like it because if I don't understand something I can ask it to tailor the response to whatever I'm working on, which helps me grasp the concept quicker. Thanks to my impatience/eagerness I think I struggle to learn sometimes because while I'm trying to understand the concept behind something I also have to keep converting the context from the example to well in this case, ProTools/Audio, which slows things down.

                                  My classic example was objects - all online literature use peoples names, age, height, object.udpateAge etc rather than track name, song name, bitDepth, etc. It's embarrassing to read that back now, but it was a real head-scratcher when learning.

                              2. In reply toTristan⬆:

                                Damn - it can even interpret what a script does:
                                I fed it this script:
                                (Pro Tools) Code to apply macros to only highlighted track? #post-3
                                "The code is for a script that is used to paste samples from a clipboard to a destination track in Pro Tools. It starts by activating the main window and invalidating it. Then it prompts the user to select a source track and a destination track, and verifies that only one track is selected for each. The script then checks if the source and destination tracks are the same, and if not, it asks the user if they want to paste the samples for the whole track or just the current selection. Based on the answer, it adjusts the selection and moves the edit cursor to the beginning of the audio. The script then tabs to the next transient and pastes the sample in the destination track as long as the insert point is earlier than the end of the selection."

                                1. In reply toTristan⬆:
                                  Brenden @nednednerb
                                    2023-01-13 21:36:28.111Z

                                    I was trying to figure out how to use one key command to toggle between min:secs, timecode, and samples on the main counter. I was working on my own with if/else statements and not getting it. GPT helped me see I could use "If... Else If... Else If" and even gave me the hint to chain the logic of the last "Else If" to go back to the first case. I quickly progressed from scratching my head to finding a fully functional solution.

                                    Something I am very interested in is the eventually paid service that companies such as SF would be able to provide to hand train the bot to validate its use for troubleshooting. One could make a bot for use on a forum or "AI Support Chat," which is truly next level, like GPT already is, but trained and honed with real qualified answers.

                                    The key to GPT is that humans spend hours validating the answers. Now, it provides statistically likely answers that will be received as valid answers. Sometimes hitting the "reload" button on the answer it provides is a very good thing to do, especially when you are wanting another answer!