Ai Coding Tools

How to Use GitHub Copilot to Write Your First Function in 30 Minutes

By BTW Team3 min read

How to Use GitHub Copilot to Write Your First Function in 30 Minutes

If you're a beginner looking to dip your toes into coding, you might feel overwhelmed by the sheer amount of information out there. Writing your first function can feel like a daunting task, but it doesn’t have to be. With GitHub Copilot, you can leverage AI to help you write code more efficiently. In this tutorial, I’ll walk you through how to use GitHub Copilot to write your first function in just 30 minutes.

Prerequisites

Before diving in, here’s what you’ll need:

  • GitHub Account: You can sign up for free at GitHub.
  • Visual Studio Code (VS Code): Download and install it from VS Code.
  • GitHub Copilot: Subscribe to GitHub Copilot for $10/month after a 60-day free trial.

Step 1: Set Up Your Environment (5 minutes)

  1. Install Visual Studio Code if you haven't already.
  2. Install the GitHub Copilot extension:
    • Open VS Code.
    • Go to Extensions (Ctrl+Shift+X).
    • Search for "GitHub Copilot" and click "Install".
  3. Sign in to your GitHub account when prompted.

Step 2: Create a New File (5 minutes)

  1. In VS Code, create a new file by clicking on File > New File.
  2. Save the file with a .js extension (e.g., firstFunction.js). This tells VS Code that you want to write JavaScript.

Step 3: Start Writing Your First Function (15 minutes)

  1. Type a comment in your file describing what you want your function to do. For example:

    // Function to add two numbers
    
  2. Activate GitHub Copilot by starting to type the function definition. As you type, suggestions will appear. For example:

    function add(a, b) {
    

    Copilot might suggest the full implementation. Accept it by pressing Tab.

  3. Complete Your Function: Make sure the code looks something like this:

    function add(a, b) {
        return a + b;
    }
    
  4. Test Your Function: Add a few lines below your function to test it:

    console.log(add(2, 3)); // Outputs: 5
    console.log(add(10, 20)); // Outputs: 30
    
  5. Run Your Code: You can use the terminal in VS Code to run your code. Open the terminal (`Ctrl+``) and type:

    node firstFunction.js
    

    You should see the output of your function in the terminal.

Troubleshooting Common Issues

  • Copilot Doesn’t Suggest Code: Ensure that the extension is enabled and you’re signed in to GitHub.
  • Code Doesn’t Run: Double-check for syntax errors. Make sure your file is saved and you’re using the correct command in the terminal.

What's Next?

Now that you’ve successfully written your first function, consider exploring more complex functions or other programming languages. You can also experiment with different prompts for Copilot to see how it can assist you in various coding tasks.

Conclusion

By following these steps, you should be able to write your first function using GitHub Copilot in about 30 minutes. It’s a powerful tool that can help you learn coding more efficiently, especially when you're just starting out. If you find yourself struggling with more complex tasks, don’t hesitate to consult resources or communities for support.

Start here: Get your GitHub account and install VS Code. Dive into writing your first function with GitHub Copilot today!

Follow Our Building Journey

Weekly podcast episodes on tools we're testing, products we're shipping, and lessons from building in public.

Subscribe

Never miss an episode

Subscribe to Built This Week for weekly insights on AI tools, product building, and startup lessons from Ryz Labs.

Subscribe
Ai Coding Tools

Cursor vs GitHub Copilot: AI Coding Assistants Compared in 2026

Cursor vs GitHub Copilot: AI Coding Assistants Compared in 2026 In 2026, the landscape of AI coding assistants has evolved significantly, with tools like Cursor and GitHub Copilot

Jul 28, 20264 min read
Ai Coding Tools

How to Create Your First Python Project Using AI Tools in Under 2 Hours

How to Create Your First Python Project Using AI Tools in Under 2 Hours If you're a solo founder or indie hacker looking to dive into Python programming but feel overwhelmed by the

Jul 28, 20265 min read
Ai Coding Tools

Why GitHub Copilot Is Overrated: An Honest Critique

Why GitHub Copilot Is Overrated: An Honest Critique As indie hackers and solo founders, we’re all looking for ways to boost our productivity without breaking the bank. Enter GitHub

Jul 28, 20265 min read
Ai Coding Tools

How to Improve Your Coding Speed with AI in Just 2 Hours

How to Improve Your Coding Speed with AI in Just 2 Hours As a solo founder or indie hacker, you know the importance of shipping quickly. But what happens when you hit a coding wall

Jul 28, 20264 min read
Ai Coding Tools

5 Underrated AI Coding Tools You Haven't Tried Yet

5 Underrated AI Coding Tools You Haven't Tried Yet As a solo founder or indie hacker, you're always on the lookout for tools that can help streamline your development process. The

Jul 28, 20264 min read
Ai Coding Tools

5 Must-Use AI Coding Tools for Beginners in 2026

5 MustUse AI Coding Tools for Beginners in 2026 As a beginner in coding, diving into the vast ocean of programming languages and tools can be overwhelming. In 2026, with advancemen

Jul 28, 20264 min read