Skip to main content
added 188 characters in body
Source Link

const str = 'Thanks for contributing an answer to Stack Overflow!'
    const substr = ['for', 'to']

    function boldString(str, substr) {
        let boldStr
        boldStr = str
        substr.map(e => {
                const strRegExp = new RegExp(e, 'g');
                boldStr= boldStr.replace(strRegExp, `<strong>${e}</strong>`);
            }
        )
        return boldStr
}

boldString(str, substr)

const str = 'Thanks for contributing an answer to Stack Overflow!'
const substr = ['for', 'to']

function boldString(str, substr) {
    let boldStr
    boldStr = str
    substr.map(e => {
            const strRegExp = new RegExp(e, 'g');
            boldStr= boldStr.replace(strRegExp, `<strong>${e}</strong>`);
        }
    )
    return boldStr
}

boldString(str, substr)

const str = 'Thanks for contributing an answer to Stack Overflow!'
    const substr = ['for', 'to']

    function boldString(str, substr) {
        let boldStr
        boldStr = str
        substr.map(e => {
                const strRegExp = new RegExp(e, 'g');
                boldStr= boldStr.replace(strRegExp, `<strong>${e}</strong>`);
            }
        )
        return boldStr
}

Source Link

const str = 'Thanks for contributing an answer to Stack Overflow!'
const substr = ['for', 'to']

function boldString(str, substr) {
    let boldStr
    boldStr = str
    substr.map(e => {
            const strRegExp = new RegExp(e, 'g');
            boldStr= boldStr.replace(strRegExp, `<strong>${e}</strong>`);
        }
    )
    return boldStr
}

boldString(str, substr)