Consider the following code segment, which removes all spaces and punctuation marks from a given phrase. The
Question:
Consider the following code segment, which removes all spaces and punctuation marks from a given phrase. The first statement performs a search to determine whether the phrase contains a space or punctuation mark. If such a character is found, then its index will be stored in the variable index and the loop test will succeed. The while loop removes the character from the phrase by concatenating the pieces of phrase that occur before and after that character and then assigning the result back to phrase. The last statement inside the loop body searches for an additional space or punctuation mark in the modified phrase. If one is found, the loop test will succeed again and the character will be deleted. This process repeats until all spaces and punctuation marks have been removed.
Using this code, define a function named Strip that takes a string as input and returns a copy of that string from which all spaces and punctuation marks have been removed. For example, the function call Strip('Foo 2 You!') should return 'Foo2You'.
Insert the Strip function definition into your string.js library file. Then, modify your strdemo.html page so that it also displays the stripped string when the button is clicked?
Step by Step Answer: