Listing 13.12 - Kallie's formatting code in a namespace
JS Bin
var kalliesCode = {
spreader: function (text, character) {
return text.split("").join(character);
},
spacer: function (text) {
return kalliesCode.spreader(text, " ");
},
dasher: function (text) {
return kalliesCode.spreader(text, "-");
}
};
Listing 13.12 - Kallie's formatting code in a namespace - Task 3
- Create a function called squasher that removes characters added by spreader.
var kalliesCode = {
spreader: function (text, character) {
return text.split("").join(character);
},
spacer: function (text) {
return kalliesCode.spreader(text, " ");
},
dasher: function (text) {
return kalliesCode.spreader(text, "-");
},
squasher: function (text, character) {
return text.split(character).join("");
}
};