Write a JavaScript function to count the occurrence of a substring in a string.