JavaScript Solution - DP
\nvar countTexts = function(pressedKeys) {\n    const MOD = 1e9 + 7;\n    const n = pressedKeys.length;\n    const dp = new Array(n + 1).fill(0);\n    \n    dp[
```\nvar countTexts = function(pressedKeys) {\n    const MOD = 1e9 + 7;\n    const n = pressedKeys.length;\n    const dp = new Array(n + 1).fill(0);\n    \n    dp[0] = 1;\n    \n    let lastChar = "";\n    let repeatCount = 0;\n    \n    for (let i = 1; i <= n; ++i) {\n        const currChar = pressedKeys[i - 1];\n        \n        if (currChar != lastChar) repeatCount = 0;\n        \n        lastChar = currChar;\n        repeatCount += 1;\n        \n        dp[i] = (dp[i] + dp[i - 1]) % MOD;\n        \n        if (i >= 2 && repeatCount >= 2) dp[i] = (dp[i] + dp[i - 2]) % MOD;\n        if (i >= 3 && repeatCount >= 3) dp[i] = (dp[i] + dp[i - 3]) % MOD;\n        if ((currChar == "7"  || currChar == "9") && i >= 4 && repeatCount >= 4) dp[i] = (dp[i] + dp[i - 4]) % MOD;\n     }\n    \n    return dp[n];\n};\n```
['Dynamic Programming', 'JavaScript']