Ai Coding Tools

How to Use GitHub Copilot to Write Your First 5 Functions

By BTW Team3 min read

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

In short

A step-by-step guide for novice developers on leveraging GitHub Copilot to quickly generate functional code snippets.

As a solo founder or indie hacker, you often find yourself juggling multiple roles—coder, marketer, and sometimes even support. The thought of writing functions from scratch can be daunting, especially when you're under pressure to ship your project. Enter GitHub Copilot, a powerful AI coding assistant that can help streamline your coding process. In this guide, I'll show you how to leverage Copilot to write your first five functions, making your coding experience smoother and more efficient.

Time Estimate

You can finish this in about 1 hour, depending on your familiarity with coding concepts.

Prerequisites

  1. A GitHub account (Free tier available).
  2. Visual Studio Code (VS Code) installed on your machine.
  3. GitHub Copilot extension installed in VS Code (Pricing: $10/month or $100/year).

Step 1: Setting Up GitHub Copilot

  1. Install Visual Studio Code: If you haven't already, download and install VS Code.
  2. Install GitHub Copilot: Open VS Code, go to Extensions (Ctrl+Shift+X), search for "GitHub Copilot," and click Install.
  3. Sign in to GitHub: After installation, you’ll need to log in to your GitHub account to activate Copilot.

Expected Output

Once set up, you’ll see Copilot's suggestions appear as you type your code.

Step 2: Writing Your First Function

Let's write a simple function that adds two numbers.

Code Snippet

function addNumbers(a, b) {
    return a + b;
}
  1. Start typing function addNumbers(a, b) and watch Copilot suggest the rest.
  2. Accept the suggestion by pressing Tab.

Step 3: Creating a Function for String Concatenation

Next, let’s create a function that concatenates two strings.

Code Snippet

function concatenateStrings(str1, str2) {
    return str1 + str2;
}
  1. Type function concatenateStrings(str1, str2) and let Copilot fill in the logic.

Step 4: Writing a Function to Check Even or Odd

Now, let's write a function that checks if a number is even or odd.

Code Snippet

function isEven(num) {
    return num % 2 === 0;
}
  1. Start with function isEven(num) and see what Copilot suggests.

Step 5: Building a Function to Find Maximum Value in an Array

Next, we’ll create a function to find the maximum value in an array.

Code Snippet

function findMax(arr) {
    return Math.max(...arr);
}
  1. Begin typing function findMax(arr) and let Copilot handle the rest.

Step 6: Crafting a Function to Reverse a String

Lastly, let’s create a function that reverses a string.

Code Snippet

function reverseString(str) {
    return str.split('').reverse().join('');
}
  1. Type function reverseString(str) and watch Copilot do its magic.

Troubleshooting

  • What could go wrong: Sometimes, Copilot's suggestions may not be accurate or irrelevant.
  • Solutions: Don’t hesitate to modify the generated code to fit your needs. Remember, it’s a tool to assist you, not replace your judgment.

What's Next

Now that you’ve written your first five functions, consider expanding your coding skills by tackling more complex problems. You can also explore integrating these functions into a simple web app or API.

Conclusion

Using GitHub Copilot can significantly speed up your coding process, especially when you're just starting. It's a great tool for indie hackers and solo founders who want to make the most of their time.

Start here: If you're new to coding, take the time to familiarize yourself with basic concepts first. Then, dive into using GitHub Copilot to enhance your coding experience.

What We Actually Use

We rely on GitHub Copilot for quick function generation while coding in JavaScript and Python. It's a great way to overcome writer's block and maintain our momentum while building.

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