freeCodeCamp/curriculum/challenges/arabic/08-coding-interview-prep/rosetta-code/count-occurrences-of-a-subs...

1.2 KiB

title id challengeType videoUrl localeTitle
Count occurrences of a substring 596fda99c69f779975a1b67d 5

Description

undefined

Instructions

undefined

Tests

tests:
  - text: ''
    testString: 'assert(typeof countSubstring === "function", "<code>countSubstring</code> is a function.");'
  - text: ''
    testString: 'assert.equal(countSubstring(testCases[0], searchString[0]), results[0], "<code>countSubstring("the three truths", "th")</code> should return <code>3</code>.");'
  - text: ''
    testString: 'assert.equal(countSubstring(testCases[1], searchString[1]), results[1], "<code>countSubstring("ababababab", "abab")</code> should return <code>2</code>.");'
  - text: ''
    testString: 'assert.equal(countSubstring(testCases[2], searchString[2]), results[2], "<code>countSubstring("abaabba*bbaba*bbab", "a*b")</code> should return <code>2</code>.");'

Challenge Seed

function countSubstring (str, subStr) {
  // Good luck!
  return true;
}

After Test

console.info('after the test');

Solution

// solution required