Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started