I'm actually new in JavaScript. I'm currently work on string matching. I can understand why it is usable and so on however whenever I'm trying to make it dynamic my output is 'null' for some reason.
function matchString(str, match) {
let result = str.match('/' + match + '/g');
console.log('Output: ' + result);
}
matchString('Hello Stack Overflow', 'over'); // null
function matchString(str, match, para) {
let result = str.match('/' + match + '/' + para);
console.log('Output: ' + result);
}
matchString('Hello Stack Overflow', 'over', 'g'); // null
I want it to output 'Over' in my console