JavaScript code to find number of subsequences of " ab " in the string S which is repeated K times .
function countOccurrences ( s , K ) { let n = s . length ; let C = 0 , c1 = 0 , c2 = 0 ; for ( let i = 0 ; i < n ; i ++ ) { if ( s [ i ] == ' ' )