You are viewing a single comment's thread. Return to all comments →
perhaps you don't need to use filter if you split str by 'a'
const repeatedString = (s, n) => { const countA = s => s.split('a').length - 1; let len = s.length; let reps = Math.floor(n / len); let remainder = s.slice(0, n % len); return reps * countA(s) + countA(remainder); };
Seems like cookies are disabled on this browser, please enable them to open this website
Repeated String
You are viewing a single comment's thread. Return to all comments →
perhaps you don't need to use filter if you split str by 'a'