JSFiddle - React, Tailwind, and code Playground

by Jessie Lau

JavaScript

function SimpleSymbols(str) {
    if (str.length > 0 && str.match(/[a-z]/i)) {
        for (var i = 0; i < str.length; i++) {
            if (str[i].match(/[a-z]/i) && (str[i - 1] !== "+" || str[i + 1] !== "+")) {
                return false;
            }
        }
    }
    return true;
}

console.log(SimpleSymbols("+d+=3=+s+"));
console.log(SimpleSymbols("+d+=3=+s"));