Logo

Executing code with extension

Experience seamless code execution with the JDoodle Extension

The main function of the JDoodle Chrome extension is to let users execute code without leaving their browser. There are two ways in which a user can execute code on the Chrome extension.

Right-click code execution

The first way to execute code in the browser extension is through a shortcut. Here’s how:

  1. If you find a code on a browser (website, email, AI tools like ChatGPT, Gemini, or JDroid), select the code snippet’ press right-click, and select “Execute with JDoodle.
  2. The Chrome extension gets launched on the right side of the screen.
  3. Your code will get automatically pasted. Set the language and version manually if not detected by JDroid.
  4. You can make edits if needed and press execute.

ExecutecodeusingJDoodlein4steps-Step3-ezgif.com-webp-to-gif-converter.gif

Pasting code in the Extension

Here are the steps to execute code from the browser onto the Chrome extension:

  1. Open the JDoodle Chrome extension.
  2. Select the preferred language and version of the programming language.
  3. Delete the pre-written code on the extension if any code is there.
  4. Type your code or paste it, then select the language and version.
  5. You can edit your code even after it’s pasted onto the extension.
  6. Press the ‘execute ’ button that directs you to the output page.

Clickright-clickandexecuteinJDoodlewithJDroid.-Step1-ezgif.com-webp-to-gif-converter.gif

How to customize the Extension tab size?

The size of the JDoodle Chrome extension can be changed according to the user’s needs. On the panel where the extension connects to the browser screen, a user can simply drag and re-adjust the size of the extension by bringing your cursor around the partition line between the browser tab and extension tab. GooglechromeWorkflow-Step12-ezgif.com-webp-to-gif-converter.gif

Try these examples

If you’ve installed the Chrome extension, you can select the below code, press right-click, select ‘execute with JDoodle,’ and execute the code with the Chrome extension.

Sample Python code to reverse a string:

def reverse_string(s):
    return s[::-1]

# Input string
original_string = "Hello, World!"

# Call the function to reverse the string
reversed_string = reverse_string(original_string)

# Print the original and reversed string
print("Original String:", original_string)
print("Reversed String:", reversed_string)

Sample Java code binary search algorithm:

public class BinarySearch {
    public static void main(String[] args) {
        int[] arr = { 3, 6, 9, 12, 15, 18, 21, 24, 27, 30 };
        int target = 18;
        int result = binarySearch(arr, target);
        if (result == -1) {
            System.out.println("Element not present");
        } else {
            System.out.println("Element found at index " + result);
        }
    }

    public static int binarySearch(int[] arr, int x) {
        int l = 0, r = arr.length - 1;
        while (l <= r) {
            int m = l + (r - l) / 2;

            if (arr[m] == x)
                return m;

            if (arr[m] < x)
                l = m + 1;

            else
                r = m - 1;
        }

        return -1;
    }
}

Sample currency converter program in C++:

#include <iostream>

using namespace std;

double convertCurrency(double amount, int option) {
    // Conversion rates based on a hypothetical scenario
    const double USD_TO_GBP = 0.82;
    const double USD_TO_EUR = 0.95;
    const double GBP_TO_USD = 1.22;
    const double GBP_TO_EUR = 1.16;
    const double EUR_TO_USD = 1.05;
    const double EUR_TO_GBP = 0.86;

    double convertedAmount = 0.0;

    switch (option) {
        case 1: // USD to GBP
            convertedAmount = amount * USD_TO_GBP;
            break;
        case 2: // USD to EUR
            convertedAmount = amount * USD_TO_EUR;
            break;
        case 3: // GBP to USD
            convertedAmount = amount * GBP_TO_USD;
            break;
        case 4: // GBP to EUR
            convertedAmount = amount * GBP_TO_EUR;
            break;
        case 5: // EUR to USD
            convertedAmount = amount * EUR_TO_USD;
            break;
        case 6: // EUR to GBP
            convertedAmount = amount * EUR_TO_GBP;
            break;
        default:
            cout << "Invalid option selected." << endl;
    }

    return convertedAmount;
}

int main() {
    double amount;
    int option;

    cout << "Welcome to the Currency Converter!" << endl;
    cout << "Please enter the amount you want to convert: ";
    cin >> amount;

    cout << "Select the conversion option:" << endl;
    cout << "1: USD to GBP" << endl;
    cout << "2: USD to EUR" << endl;
    cout << "3: GBP to USD" << endl;
    cout << "4: GBP to EUR" << endl;
    cout << "5: EUR to USD" << endl;
    cout << "6: EUR to GBP" << endl;
    cin >> option;

    double convertedAmount = convertCurrency(amount, option);
    if (convertedAmount != 0.0) {
        cout << "Converted amount: " << convertedAmount << endl;
    }

    return 0;
}

Need help?

Please let us know by filling out this contact form if you have any questions or queries. You can also post your questions on our discord community. You can also refer to this documentation for FAQs.