Question: In JavaScript: Write a function named compress(), that accepts a sentence containing blanks and punctuation and returns a string that is the sentence with all

In JavaScript: Write a function named compress(), that accepts a sentence containing blanks and punctuation and returns a string that is the sentence with all blanks and punctuation removed. This function must call isWhiteSpace() and isPunct(). // My isWhiteSpace() and isPunct() functions

function isWhiteSpace(str) { return str.replace(/^\s+|\s+$/g, '').length == 0; } isWhiteSpace (" ")

function isPunct(myChar){ var pattern = /[:;,.?!-'"(){}]/; return pattern.test(myChar); } isPunct("?")

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!