Advertisement
dimipan80

Replace the White-Spaces

Nov 12th, 2014
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* Write a JavaScript function replaceSpaces(str) that replaces the white-space characters in a text with  .
  2. Write JS program spaceReplacer.js that invokes your function with the sample input data below and prints
  3. the output at the console. */
  4.  
  5. "use strict";
  6.  
  7. function replaceSpaces(str) {
  8.     str = str.replace(/\s/g, '');
  9.     return str;
  10. }
  11.  
  12. console.log(replaceSpaces("But you were living in another world tryin' to get your message through"));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement