DEV Community

Lam
Lam

Posted on

ChatGPT Coding CheatSheets

Explain why a piece of code isn't working

Why this code is not working?
var x = 5;
var y = 0;
console.log(x/y);
Enter fullscreen mode Exit fullscreen mode

Explain what a piece of code means

What does this code do?
function addNumbers(a, b) {
    return a + b;
}
Enter fullscreen mode Exit fullscreen mode

*Rewrite the code using the specified language

Translate this code into Python:
function addNumbers(a, b) {
    return a + b;
}
Enter fullscreen mode Exit fullscreen mode

Code an entire software program

Write a program that calculates the factorial of a given number in python.
How do I make an HTTP request in Javascript?
Enter fullscreen mode Exit fullscreen mode

Generate regular expressions (regex)

Create a regex that matches all email addresses?
Generate 8-digit password regex
Enter fullscreen mode Exit fullscreen mode

Add comments to your codebase

Add comments to this code: 
function addNumbers(a, b) {
    return a + b;\n}
Enter fullscreen mode Exit fullscreen mode

Change the CSS of a line of code

Update the CSS for this line to change the font color to blue?
<p class=\"example\">Hello, QuickRef.ME!</p>
Enter fullscreen mode Exit fullscreen mode

Change the HTML of a line of code

Add a class of \"header\" to this header tag?
<h1>Hello, QuickRef.ME!</h1>
Enter fullscreen mode Exit fullscreen mode

References:

Top comments (0)