Ai Coding Tools

How to Use GitHub Copilot to Write Your First 5 Functions in Under 30 Minutes

By BTW Team3 min read

How to Use GitHub Copilot to Write Your First 5 Functions in Under 30 Minutes

If you’re a solo founder or indie hacker looking to speed up your coding process, GitHub Copilot can feel like a magic wand. But let’s be real: it can also be overwhelming for beginners. You might be thinking, “Can this AI really help me write functions quickly?” Spoiler alert: Yes, it can, and I’m going to show you how to write your first five functions in under 30 minutes.

Prerequisites: What You Need to Get Started

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

  • GitHub Account: Free to create if you don't have one.
  • Visual Studio Code (VS Code): Download and install it.
  • GitHub Copilot Subscription: $10/month or $100/year after a free trial.
  • Basic Understanding of JavaScript or Python: Familiarity will help, but don’t worry if you’re just starting out.

Step 1: Setting Up GitHub Copilot

  1. Install VS Code: Go to the VS Code website and download the latest version.
  2. Install Copilot: Open VS Code, go to Extensions (Ctrl+Shift+X), and search for "GitHub Copilot." Click "Install."
  3. Sign In: Once installed, click on the Copilot icon in the sidebar and sign in with your GitHub account. You’ll need to activate your subscription if you haven't already.

Expected Output: You should see a Copilot icon in the bottom-right corner of your VS Code window, indicating it's ready to assist.

Step 2: Writing Your First Function

Function 1: Simple Addition

  1. Open a new file (e.g., functions.js).
  2. Type function add(a, b) { and hit Enter.
  3. Copilot will suggest the function body. Accept the suggestion.

Expected Output: A function that adds two numbers and returns the result.

Function 2: String Reversal

  1. Below the previous function, type function reverseString(str) { and hit Enter.
  2. Accept Copilot’s suggestion for reversing the string.

Expected Output: A function that takes a string and returns it reversed.

Function 3: Factorial Calculation

  1. Add function factorial(n) { and hit Enter.
  2. Let Copilot generate the logic for calculating the factorial.

Expected Output: A function that computes the factorial of a number.

Function 4: Checking for Prime Numbers

  1. Type function isPrime(num) { and hit Enter.
  2. Accept the suggested code that checks if the number is prime.

Expected Output: A function that returns true if the number is prime, false otherwise.

Function 5: FizzBuzz

  1. Finally, type function fizzBuzz(n) { and hit Enter.
  2. Let Copilot fill in the logic for the classic FizzBuzz problem.

Expected Output: A function that prints "Fizz", "Buzz", or "FizzBuzz" for numbers from 1 to n.

Troubleshooting: What Could Go Wrong

  1. Copilot Doesn’t Suggest Code: Make sure you’re online and logged in. Sometimes, simply restarting VS Code can help.
  2. Incorrect Suggestions: If Copilot suggests something that doesn’t make sense, you can type a comment describing what you want, and it will adjust its suggestions accordingly.
  3. Function Errors: Test each function after writing it to ensure it behaves as expected. If it doesn’t, debug the code as you would normally.

What’s Next: Building on Your Functions

After you’ve written these functions, consider integrating them into a simple project. For instance, you could create a basic calculator or a small game that utilizes your functions. This will reinforce your learning and give you practical experience.

Conclusion: Start Here

If you're looking to enhance your coding speed and efficiency, GitHub Copilot is a fantastic tool. Follow the steps outlined above, and you’ll have your first five functions written in no time. Remember, while Copilot can give you a head start, always review and understand the code it generates.

In our experience, GitHub Copilot is worth the investment for anyone serious about coding efficiently, especially if you’re working on side projects or building products.

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

Bolt.new vs GitHub Copilot: Which is the Best AI Coding Partner for 2026?

Bolt.new vs GitHub Copilot: Which is the Best AI Coding Partner for 2026? As a solo founder, you know the pressure of shipping code quickly while maintaining quality. The right AI

May 4, 20263 min read
Ai Coding Tools

Bolt.new vs GitHub Copilot: Which is Best for Rapid Development?

Bolt.new vs GitHub Copilot: Which is Best for Rapid Development? As indie hackers and solo founders, we all crave tools that can help us move faster. In 2026, two popular AI coding

May 4, 20263 min read
Ai Coding Tools

How to Master AI-Powered Pair Programming in 30 Minutes

How to Master AIPowered Pair Programming in 30 Minutes As indie hackers and solo founders, we often wear multiple hats, and coding can sometimes feel like the heaviest one. Enter A

May 4, 20264 min read
Ai Coding Tools

How to Write Your First Script with Cursor AI in Just 30 Minutes

How to Write Your First Script with Cursor AI in Just 30 Minutes If you're a solo founder or indie hacker looking to dip your toes into coding, you might feel overwhelmed by the pr

May 4, 20264 min read
Ai Coding Tools

Bolt.new vs GitHub Copilot: Which AI Coding Assistant is Better for Solo Developers?

Bolt.new vs GitHub Copilot: Which AI Coding Assistant is Better for Solo Developers? As a solo developer, finding the right tools to streamline your coding process can feel like se

May 4, 20263 min read
Ai Coding Tools

How to Write Code 5x Faster Using AI Tools: A Step-by-Step Tutorial

How to Write Code 5x Faster Using AI Tools: A StepbyStep Tutorial In 2026, the landscape of coding has shifted dramatically thanks to AI tools that promise to make us faster and mo

May 4, 20265 min read