JSFiddle - React, Tailwind, and code Playground

by Ray Cal

JavaScript

$(function () {

    function find ( str, key){ 
        var count = count||0;
        if (str.length<=key.length){
            if (str.substr(0,key.length)===key){
                return 1
            }
                return 0
        }
        if( str[0] === key[0] ){
            count += find( str.slice(1), key.slice(1) )
        }
        count += find(str.slice(1),key )
        return count 


}


var two = find('foobarfoo','foo');
console.log(two);
    
});