Can GitHub Copilot solve JavaScript interview questions?
🤖 GitHub Copilot is one of the coolest applications of AI. In this article, let’s find out, is it capable of solving JavaScript interview questions.

There are several fascinating applications of artificial intelligence and machine learning in our daily lives. AI is helping us in all aspects of our life, whether we’re attempting to read our emails, obtain driving directions, or find music or movie suggestions.
AI has even made its way to improve developers productivity, which is impacting developers in their daily tasks and at workplace. Further speaking it has become capable to write code which can assist developers and helps them in developing software much faster and easier.

Today we will be looking into one of the coolest AI applications, GitHub Copilot, which is capable of writing code. I got access to GitHub Copilot few days back and have been trying it out, whenever i write a piece of code. I found it really amazing, to be honest it blew my mind. In order to explore more of its capabilities i tried giving it few JavaScript interview questions.
Before starting let’s understand what exactly GitHub Copilot is
What is GitHub Copilot exactly?

GitHub Copilot is your AI pair programmer that can help you write code faster and with less work. It draws context from the code you’re working on, suggesting whole lines or entire functions. It helps you quickly discover alternative ways to solve problems, write tests, and explore new APIs without having to tediously tailor a search for answers on the internet. As you type, it adapts to the way you write code, to help you complete your work faster.
GitHub Copilot provides suggestions for dozens of languages and a wide variety of frameworks, but it works especially well for Python, JavaScript, TypeScript, Ruby, and Go. — Team GitHub Copilot
GitHub Copilot utilizes OpenAI Codex, a modified version of GPT-3 (a language model meant to generate human-like writing) that is intended to generate legitimate computer code. Copilot is trained on public GitHub repositories.
For more information: https://copilot.github.com/
Gist of copilot
Let’s check some of the amazing tasks copilot can perform and know its potential .
In order to let copilot suggest you code, you need give what are your exact requirements through comments. The below example is about creating a class named Person with first name, last name as a property and greet as a method. So I described the above scenario and now it fully predicted functional code.

Click on Tab
key to accept the solution

It also created object from the class with first-name and last-name


And it’s as simple as that, this is just a simple example it can do more complex tasks.
Some more examples


Enough speaking!!
Let’s start interviewing copilot :)
I picked 10 questions from the following websites
Level: Basic
Note: It predicts the answer line by line, as every line prediction can’t be shown, i have showed the final output.
1. What are JavaScript Data Types?

2.What are global variables? How are these variable declared?

3. How to write a function in JavaScript?

4. Explain “this” keyword in detail.

5. Explain in detail about == and ===

In my opinion it pretty much explained all the basic questions accurately. But it gave single line answers and one short example, it’s cant predict in-depth answers
Level: Medium
6. What is Object Destrcturing?

7. What is a Promise in JavaScript?

8. What is the role of deferred scripts in JavaScript?

9. What is the rest parameter and spread operator?

10. Explain Try catch in JavaScript

Bonus:

Conclusion
In my opinion, It answered all the questions accurately but it still lacks in depth explanation. So now you may have realized why one liners don't work in an interview, so try taking your answer as deep as possible. One more thing i like about copilot while predicting answers is it backed it’s statement by an example which is appreciable and tells more about the answer, so try giving more examples in any interview.
Though this interview experiment is for fun, giving interviews is not the expertise of copilot, the main service/motto of copilot is to help developers in their day to day coding tasks and make developer experience better. From analyzing all the tasks it has been doing, it’s evident that it succeeded and has been helping the developers to write better code. I personally loved it and i am waiting for more updates.
That’s it for the article, thank you for reaching the end 🙌, hope you enjoyed it. If you liked the article don’t forget to give a clap :)
