Ai Coding Tools

How to Use GitHub Copilot to Write Your First 5 Functions

By BTW Team3 min read

How to Use GitHub Copilot to Write Your First 5 Functions

If you're a beginner coder, you might feel overwhelmed by the prospect of writing functions from scratch. Enter GitHub Copilot, the AI-powered coding assistant that can help you write functions quickly and efficiently. But how do you actually use it effectively? In this guide, I'll walk you through how to leverage GitHub Copilot to write your first five functions, and we’ll keep it practical and straightforward.

Time Estimate: 1-2 hours

Prerequisites:

  • A GitHub account
  • Visual Studio Code (or any IDE that supports GitHub Copilot)
  • GitHub Copilot subscription ($10/month after a 60-day free trial)

Getting Started with GitHub Copilot

Before diving into writing functions, let’s set up GitHub Copilot.

  1. Install Visual Studio Code: If you haven't already, download and install VS Code from here.
  2. Install GitHub Copilot: Search for the GitHub Copilot extension in the Extensions Marketplace within VS Code, and install it.
  3. Sign in to GitHub: Once installed, you'll need to sign in to your GitHub account to activate Copilot.

Step-by-Step: Writing Your First 5 Functions

1. Function to Add Two Numbers

Type the following comment in your code editor:

// Function to add two numbers

Hit enter, and GitHub Copilot will suggest a function. Accept the suggestion by pressing the Tab key if it looks good. Your function should look something like this:

function add(a, b) {
    return a + b;
}

2. Function to Check Even or Odd

Next, add another comment:

// Function to check if a number is even or odd

Again, hit enter and let Copilot suggest a function. You might get:

function isEven(num) {
    return num % 2 === 0;
}

3. Function to Find the Maximum of Three Numbers

For your third function, type:

// Function to find the maximum of three numbers

Accept the suggestion for the function:

function maxOfThree(a, b, c) {
    return Math.max(a, b, c);
}

4. Function to Reverse a String

Now, let’s reverse a string. Type:

// Function to reverse a string

Copilot should suggest:

function reverseString(str) {
    return str.split('').reverse().join('');
}

5. Function to Count Vowels in a String

Finally, let’s count the vowels in a string. Type:

// Function to count vowels in a string

You might get a suggestion like this:

function countVowels(str) {
    return str.match(/[aeiou]/gi).length || 0;
}

Troubleshooting: What Could Go Wrong

  • Copilot Doesn't Suggest Anything: If Copilot isn't providing suggestions, check if you’re connected to the internet and that you've signed in properly.
  • Incorrect Functionality: Always test the functions you create. AI isn't perfect, and sometimes the suggestions may not work as intended.

What's Next?

Now that you've written your first five functions, consider building a small project that incorporates these functions. For instance, create a simple calculator or a string manipulation tool. You can also explore more complex functions or dive into integrating with APIs.

Conclusion

Using GitHub Copilot can significantly speed up your coding process, especially when you're starting out. It’s not a replacement for learning how to code, but it can guide you in the right direction. My recommendation? Start with simple functions like the ones we've covered here.

If you find Copilot helpful, consider keeping it as part of your coding toolkit. Just remember to validate the outputs and keep learning!

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

How to Automate Your Coding Workflow Using AI in 4 Steps

How to Automate Your Coding Workflow Using AI in 4 Steps If you’re a solo founder or indie hacker like me, you know that time is your most precious resource. In 2026, the landscape

Jun 12, 20264 min read
Ai Coding Tools

Why Cursor is Overrated: My Experience After 6 Months

Why Cursor is Overrated: My Experience After 6 Months As an indie hacker, I’m always on the lookout for tools that genuinely enhance my productivity and streamline my workflow. Whe

Jun 12, 20263 min read
Ai Coding Tools

How to Build Your First AI Chatbot in Just 2 Hours

How to Build Your First AI Chatbot in Just 2 Hours Building your first AI chatbot can feel daunting, especially if you're not a seasoned developer. But here’s the thing: it doesn't

Jun 12, 20264 min read
Ai Coding Tools

Supabase vs Firebase: The Best Choice for Your AI Backend in 2026

Supabase vs Firebase: The Best Choice for Your AI Backend in 2026 When it comes to building an AI backend, choosing the right database can feel overwhelming. With numerous options

Jun 12, 20263 min read
Ai Coding Tools

AI Coding Tools: Bolt.new vs GitHub Copilot - Which is Best for Collaboration?

AI Coding Tools: Bolt.new vs GitHub Copilot Which is Best for Collaboration? As a solo founder or indie hacker, finding the right tools to streamline your coding workflow is essen

Jun 12, 20263 min read
Ai Coding Tools

Best 7 AI Coding Tools for Beginner Solo Developers in 2026

Best 7 AI Coding Tools for Beginner Solo Developers in 2026 As a beginner solo developer, diving into the world of coding can be overwhelming. You might find yourself asking, "Wher

Jun 12, 20265 min read