Check if a string consists of a repeated character sequence
JavaScript
const consistsRepeatedSubstring = (str) => `${str}${str}`.indexOf(str, 1) !== str.lengthTypeScript
const consistsRepeatedSubstring = (str: string): boolean => `${str}${str}`.indexOf(str, 1) !== str.lengthExamples
consistsRepeatedSubstring('aa') // true
consistsRepeatedSubstring('aaa') // true
consistsRepeatedSubstring('ababab') // true
consistsRepeatedSubstring('abc') // false