diff --git a/solution/2400-2499/2414.Length of the Longest Alphabetical Continuous Substring/README_EN.md b/solution/2400-2499/2414.Length of the Longest Alphabetical Continuous Substring/README_EN.md index 4f7e9a104ccb2..3950287058347 100644 --- a/solution/2400-2499/2414.Length of the Longest Alphabetical Continuous Substring/README_EN.md +++ b/solution/2400-2499/2414.Length of the Longest Alphabetical Continuous Substring/README_EN.md @@ -196,8 +196,30 @@ int longestContinuousSubstring(char* s) { } ``` +###js + +````JavaScript + * @param {string} s + * @return {number} + */ +var longestContinuousSubstring = function(s) { + let max = 0, curr = 0, prev = 0, i = 0, c = 0; + + while (i < s.length) { + c = s.charCodeAt(i); + curr = (c === prev + 1) ? curr + 1 : 1; + max = (curr > max) ? curr : max; + prev = c; + i++; + } + + + return max; +};``` + +````