JSFiddle - React, Tailwind, and code Playground

by Alfie

JavaScript

//You can create a function for string and use eval()


    test = function (calc) {
        return calc;
    }
    String.prototype.calculate = function (num1, num2) {
        return eval(num1 + this.toString() + num2)
    }
    test('*').calculate(2,3)//returns 6