function findSimilarity(str, word) {
const reg = /(^.)(.*)(.$)/g;
word = reg.exec(word);
const findSpaceRegex = /([^ ]+)/g;
str = str.match(findSpaceRegex);
return str.map((e) => {
if (
reg.exec(word)[1] == reg.exec(e)[1] &&
reg.exec(word)[2].length == reg.exec(e)[2].length &&
reg.exec(word)[0] != reg.exec(e)[0] &&
reg.exec(word)[3] == reg.exec(e)[3]
)
console.log(true);
});
}
console.log(findSimilarity("bag dog dig dot doog dogs", "dog"));
this is my code and when i try to solve this https://www.codewars.com/kata/573975d3ac3eec695b0013e0/train/javascript kata i use exec but problem is exec working just once. than when i want to exec all of them its says null but the problem is not null. when i say a.match(Regex) its work well but it does not need my needs. so what is my problem or what is map problemler i want to thanks to right know for answering question.