Need help with manipulating paragraph
Posted on 2014-09-23
a. countWordsBeginningWith: this method should return the amount of words that begin with an inputted string. The optional second parameter (integer representing the sentence) should determine what sentence the words come from when present.
b. getWordsSorted: this method should return a sorted list of words. The first parameter should be the sorting function used to sort words (length, alphabetization, and reverse alphabetization), the optional second parameter should determine the sentence to pull words from (integer representing the sentence).
var sampleData = 'My experience in the nature study area was full of surprises. First of all, many unexpected creatures crossed our path! For example, as soon as we left the parking area and entered the grassy path, a long snake slithered along the edge of the high grass and quickly disappeared. In addition, I was surprised by how colorful the grasses, which from a distance all appear to be green, actually are.';
a. sample output 1: countWordsBeginningWith('ex') ---> experience, example
a. sample output 2: countWordsBeginningWith('ex',1) ---> experience
b. sample output 1: getWordsSorted('length') ---> list of longest to shortest
b. sample output 1: getWordsSorted('length',1) ---> list of longest to shortest in first sentence only