function solveBooleanFunction(inputListNames, booleanExpression) {
    let i;
    let j;
    let output = [];

    if (booleanExpression.match(/[^ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01+'() ]/g) != null) {
        alert('One of the characters is not allowed.');
        return;
    }

    if (inputListNames.length > 8) {
        alert('You can only have 8 variables at a time.');
        return;
    }

    var s = '<table  class="content-table">';
    s += '<tbody style="display:block; max-height:70vh; overflow-y:scroll" >';
    s += '<tr>';
    if ($('#decimalColumnBox').is(':checked')) { s += '<th>' + 'dec' + '</th>'; }
    for (i = 0; i < inputListNames.length; i++) { s += `<th>${inputListNames[i]}</th>`; }
    s += `<th>${booleanExpression}</th>`;
    s += '</tr>';
    var matrix = [];
    for (i = 0; i < inputListNames.length; i++) {
        matrix[i] = new Array((inputListNames.length));
    }

    for (i = 0; i < inputListNames.length; i++) {
        for (j = 0; j < (1 << inputListNames.length); j++) {
            matrix[i][j] = (+((j & (1 << (inputListNames.length - i - 1))) != 0));
        }
    }
    // generate equivalent expression by replacing input vars with possible combinations of o and 1
    for (i = 0; i < (2 ** inputListNames.length); i++) {
        const data = [];
        for (j = 0; j < inputListNames.length; j++) {
            data[j] = Math.floor(i / Math.pow(2, inputListNames.length - j - 1)) % 2;
        }
        let equation = booleanExpression;
        for (j = 0; j < inputListNames.length; j++) {
            equation = equation.replace(new RegExp(inputListNames[j], 'g'), data[j]);
        }

        output[i] = solve(equation);
    }

    for (j = 0; j < (1 << inputListNames.length); j++) {
        s += '<tr>';
        if ($('#decimalColumnBox').is(':checked')) { s += `<td>${j}</td>`; }
        for (i = 0; i < inputListNames.length; i++) {
            s += `<td>${matrix[i][j]}</td>`;
        }

        s += `<td class="13" id="${j}">` + `${output[j]}` + '</td>';
        s += '</tr>';
    }

    s += '</tbody>';
    s += '</table>';
    // generates solution for the truth table of booleanexpression
    function solve(equation) {
        while (equation.indexOf("(") != -1) {
            const start = equation.lastIndexOf("(");
            const end = equation.indexOf(")", start);
            if (start != -1) {
                equation = equation.substring(0, start)
                + solve(equation.substring(start + 1, end))
                + equation.substring(end + 1);
            }
        }
        equation = equation.replace(/''/g, '');
        equation = equation.replace(/0'/g, '1');
        equation = equation.replace(/1'/g, '0');
        for (let i = 0; i < equation.length - 1; i++) {
            if ((equation[i] == '0' || equation[i] == '1') && (equation[i + 1] == '0' || equation[i + 1] == '1')) {
                equation = equation.substring(0, i + 1) + '*' + equation.substring(i + 1, equation.length);
            }
        }
        try {
            const safeEval = eval;
            const answer = safeEval(equation);
            if (answer == 0) {
                return 0;
            }
            if (answer > 0) {
                return 1;
            }
            return '';
        } catch (e) {
            return '';
        }
    }

    return output;
}
This function solves passed boolean expression and returns
output array which contains solution of the truth table
of given boolean expression
@param {Array}  inputListNames - labels for input nodes
@param {String} booleanExpression - boolean expression which is to be solved