Files
30-seconds-of-code/test/isSimilar/isSimilar.js
2018-08-03 19:51:50 +00:00

6 lines
243 B
JavaScript

const isSimilar = (pattern, str) =>
[...str].reduce(
(matchIndex, char) => char.toLowerCase() === (pattern[matchIndex] || '').toLowerCase() ? matchIndex + 1 : matchIndex, 0
) === pattern.length ? true : false;
module.exports = isSimilar;