Get Programming with JavaScript - Listing 15.08
Listing 15.08 - A message view
JS Bin
(function () {
var getMessageInfo = function (messageData) {
return "*** " + messageData + " ***";
};
var render = function (message) {
console.error(getMessageInfo(message));
};
if (window.theCrypt === undefined) {
window.theCrypt = {};
}
theCrypt.messageView = {
render: render
};
})();
Further Adventures
Listing 15.08 - A message view - Task 4
- Change the program to display messages like "The message is: Hello"
(function () {
var getMessageInfo = function (messageData) {
return "The message is: " + messageData;
};
var render = function (message) {
console.error(getMessageInfo(message));
};
if (window.theCrypt === undefined) {
window.theCrypt = {};
}
theCrypt.messageView = {
render: render
};
})();
Listing 15.08 - A message view - Task 5
- Change the program to display messages in upper case.
(function () {
var getMessageInfo = function (messageData) {
return messageData.toUpperCase();
};
var render = function (message) {
console.error(getMessageInfo(message));
};
if (window.theCrypt === undefined) {
window.theCrypt = {};
}
theCrypt.messageView = {
render: render
};
})();