Ai Coding Tools

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

By BTW Team3 min read

Comparing tools? See the AI tools tested on the show.

In short

A step-by-step guide on how to harness the power of GitHub Copilot to write your first function seamlessly in just 30 minutes.

If you've ever felt overwhelmed staring at a blank code editor, you're not alone. As a solo founder or indie hacker, finding ways to speed up your development process is crucial. That's where GitHub Copilot comes in. In just 30 minutes, you can start writing your first function with the help of AI. This guide will walk you through the process, including what you need to get started and how to troubleshoot common issues.

Prerequisites: What You Need

Before diving in, make sure you have the following:

  1. GitHub Account: Sign up for free if you don’t have one.
  2. Visual Studio Code: Download and install this popular code editor.
  3. GitHub Copilot Subscription: GitHub Copilot costs $10/month or $100/year, with a free trial available for new users.
  4. Basic Understanding of JavaScript: While Copilot can help, knowing the basics will make the experience smoother.

Step-by-Step Guide to Writing Your First Function

Step 1: Install GitHub Copilot

  1. Open Visual Studio Code.
  2. Go to the Extensions view by clicking on the Extensions icon in the sidebar or pressing Ctrl+Shift+X.
  3. Search for "GitHub Copilot" and install the extension.
  4. Sign in with your GitHub account and authorize the extension.

Expected Output: You’ll see a small Copilot icon in the bottom right corner of VS Code indicating it’s ready to help.

Step 2: Create a New File

  1. Click on File > New File or press Ctrl+N.
  2. Save the file with a .js extension (e.g., myFunction.js).

Step 3: Start Writing Your Function

  1. Begin typing a comment to describe the function you want to write. For example:
    // A function that adds two numbers
    
  2. After typing the comment, hit Enter. Copilot will suggest a function implementation.

Expected Output: You should see a function suggestion appear just below your comment.

Step 4: Accept the Suggestion

  1. If the suggestion looks good, press Tab to accept it. If not, you can keep typing or hit Ctrl + Space for more suggestions.

Step 5: Test Your Function

  1. Below your function, call it with example parameters:
    console.log(add(2, 3)); // Expected output: 5
    
  2. Save the file and run it using Node.js or in a browser console.

Expected Output: You should see the result of the function in the console.

Troubleshooting Common Issues

  • No Suggestions Appearing: Ensure your GitHub Copilot is enabled. Check settings in VS Code under Extensions.
  • Confusing Suggestions: Sometimes, Copilot may not understand your comment. Try rephrasing it.
  • Slow Performance: If Copilot seems slow, check your internet connection. It requires an active connection to function properly.

What's Next: Expanding Your Skills

Once you've successfully written your first function, consider exploring more complex scenarios:

  • Write a Function with Conditional Logic: Try to create a function that sorts an array.
  • Integrate with APIs: Use Copilot to help build functions that interact with web APIs.
  • Explore Other Languages: GitHub Copilot supports multiple languages, so try it out with Python or Ruby.

Conclusion: Start Here

Using GitHub Copilot can drastically reduce the time it takes to write code. In just 30 minutes, you can go from zero to writing functional code. If you're looking to enhance your coding efficiency, this tool is worth every penny of its subscription fee.

What We Actually Use

In our experience, GitHub Copilot has become an essential part of our stack, especially for quick prototyping. While it’s not perfect and sometimes requires a bit of tweaking, it saves us significant time on repetitive tasks.

Watch real AI builds every week

Built This Week is a weekly podcast where Jordan Metzner and Sam Nadler build something real with AI every episode, test new AI tools and talk with founders who build with AI.

See the tools

Watch real AI builds every week

Built This Week is a weekly podcast where Jordan Metzner and Sam Nadler build something real with AI every episode, test new AI tools and talk with founders who build with AI.

See the tools
Ai Coding Tools

3 AI Coding Tools That Are Overrated (and Why You Should Avoid Them)

3 AI Coding Tools That Are Overrated (and Why You Should Avoid Them) In the everevolving landscape of AI coding tools, it's easy to get swept up in the hype. As indie hackers and s

Nov 30, 20263 min read
Ai Coding Tools

5 Ways AI Coding Tools Can Accelerate Your MVP Development in 2026

5 Ways AI Coding Tools Can Accelerate Your MVP Development in 2026 In 2026, the landscape for indie hackers and solo founders has evolved significantly, especially with the advent

Nov 26, 20264 min read
Ai Coding Tools

5 AI Coding Tools That Make Legacy Code Feel Brand New in 2026

5 AI Coding Tools That Make Legacy Code Feel Brand New in 2026 If you’re a developer stuck maintaining legacy code, you know the frustration. It’s like navigating a maze blindfolde

Nov 23, 20264 min read
Ai Coding Tools

10 AI Coding Tools That Will Save You Hours of Debugging in 2026

10 AI Coding Tools That Will Save You Hours of Debugging in 2026 Debugging can feel like a neverending cycle of frustration. Whether you're a solo founder or an indie hacker, spend

Nov 18, 20265 min read
Ai Coding Tools

10 Common Mistakes When Using AI Coding Tools for MVP Development

10 Common Mistakes When Using AI Coding Tools for MVP Development As a founder in 2026, you’re likely aware that AI coding tools can significantly speed up the MVP development proc

Nov 16, 20264 min read
Ai Coding Tools

5 AI Coding Myths Every Beginner Developer Should Ditch in 2026

5 AI Coding Myths Every Beginner Developer Should Ditch in 2026 As a beginner developer, you’ve probably come across a ton of buzz surrounding AI coding tools. But with all the hyp

Nov 12, 20263 min read