Answer to Question #168556 in HTML/JavaScript Web Application for t

Question #168556

Split and Replace


Given three strings


inputString, separator and replaceString as inputs. Write a JS program to split the

inputString with the given separator and replace strings in the resultant array with the replaceString whose length is greater than 7.


  • You can use the string method split()
  • You can use the array method map()



input:

Javascript-is-amazing

-

programming



output:

programming is amazing



input:

the&lion&king

&

tiger



output:

the lion king


1
Expert's answer
2021-03-05T08:45:19-0500
function splitReplace(inputString, separator, replaceString) {
    return inputString.split(separator).map(item => item.length > 7 ? replaceString : item).join(' ')
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS