บทความนี้สาธิตการนับ contiguous substrings ที่ประกอบด้วยตัวอักษรเดียวกันทั้งหมด ตัวอย่าง 8 ตัวอย่างโค้ด { let { length } = str; let res = length; if (!length) { return length; } for (let j = 0, i = 1; i < length; ++i) { if (str[i] === str[j]) { res += i - j; } else {