X Interview Question

How would you modify the String prototype in Javascript so that it printed out spaces in between every character?

Interview Answers

Anonymous

Jun 7, 2016

String.prototype.toSpaceString = function() { return this.split('').join(' '); }

Anonymous

Apr 29, 2016

String.prototype.toSpaceString = function(){ var s = [], c=0; while(c