Question: // Function howSwedish() // // ABBA is a band, they have many songs including Dancing Queen, and // Fernando. ABBA is actually a Swedish band,

// Function howSwedish() // // ABBA is a band, they have many songs including Dancing Queen, and // Fernando. ABBA is actually a Swedish band, so if we wanted to find // out howSwedish a String is, we could simply find out how many times // the String contains the substring "abba". We want to look for this // substring in a case insensitive manner. So "abba" counts, and so // does "aBbA". We also want to check for overlapping abba's such as // in the String "abbAbba" that contains "abba" twice. // // In short, return the number of times 'abba' occurs in sequence. // // howSwedish("ABBA a b b a") returns 1 // howSwedish("abbabba!") returns 2 // howSwedish('abbabba') returns 2); // // Precondition: The argument to sequence is always a string. // function howSwedish(sequence) { // TODO: Complete this function return // an integer }

console.log('Testing howSwedish()'); console.assert(howSwedish('xabbax') == 1); // You must add at least four more console.assert()s to test this function!

// ----------------------------------------------------------------------------------- // Function mirrorEnds() // // Complete method mirrorEnds that given a string, looks for a mirror // image (backwards) string at both the beginning and end of the given // string. In other words, zero or more characters at the very beginning // of the given string, and at the very end of the string in reverse order // (possibly overlapping). For example, "abXYZba" has the mirror end "ab". // // mirrorEnds("") returns "" // mirrorEnds("abcde") returns "" // mirrorEnds("a") returns "a" // mirrorEnds("abca") "a" // mirrorEnds("abba") returns "abba" // mirrorEnds("abbA")) returns "" (case sensitive 'a' != 'A') // // Precondition: The argument to sequence is always a string. // function mirrorEnds(sequence) { // TODO: Complete this function return // a string }

console.log('Testing mirrorEnds()') console.assert(mirrorEnds('ab12ba') === 'ab'); // You must add at least four more console.assert()s to test this function!

// ----------------------------------------------------------------------------------- // Function maxBlock() // // Given a string argument, return the length of the largest "block" in the // string sequence. A block is a run of adjacent characters that are the same. // // maxBlock("hoopla") returns 2 (has 'o's) // maxBlock("abbCCCddBBBxx") returns 3 (has three 'C's and 3 'B's) // maxBlock("BBbBbBCCC") returns 3 (thee 'C's, case sensitive) // maxBlock("") returns 0 // maxBlock("1") returns 1 // // Precondition: The argument to sequence is always a valid string. //

Javascript Thank you! I will give you a thumb up!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!