Folders problem

by alexsuch

HTML

<script src="//cdnjs.cloudflare.com/ajax/libs/mocha/1.20.1/mocha.js"></script>
<link rel="stylesheet" href=" //cdnjs.cloudflare.com/ajax/libs/mocha/1.20.1/mocha.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/chai/1.9.1/chai.min.js"></script>
<div id="mocha"></div>

JavaScript

/*
Write a function that takes in 2 string parameters, str1 and str2, and returns the number of times the characters of str2 occur as a sequence (but not necessarily next to each other) inside str1

ex: str1=”cat in a hat” and str2=”at” then function returns 4 (1st ‘a’ & 1st ‘t’, 1st ‘a’ and 2nd ‘t’, 2nd ‘a’ and 2nd ‘t’, 3rd ‘a’ and 2nd ‘t’)
*/
function getSequenceOccurrences(str1, str2) {
}

// Tests
mocha.setup('bdd');
var assert = chai.assert;

describe('getSequenceOccurrences', function () {
	it('a cat in a hat, at', () => {
  	assert.equal(getSequenceOccurrences('a cat in a hat, at'), 4);
  });
  
  it('a cat in a hat, a', () => {
		assert.equal(getSequenceOccurrences('a cat in a hat, a'), 4);
  });
  
  it('a cat in a hat, rat', () => {
  	assert.equal(getSequenceOccurrences('a cat in a hat, rat'), 0);
  });
  
  it('a cat in a hat, aat', () => {
  	assert.equal(getSequenceOccurrences('a cat in a hat, rat'), 4);
  });
  
  it('a cat in a hat, hat', () => {
  	assert.equal(getSequenceOccurrences('a cat in a hat, rat'), 1);
  });
  
    
});

mocha.run();