Response:
Code:
const example = {
scope: null,
tokens: ['alpha','bravo','charlie','delta','echo']
};
example.message = (args) => {
if(args.log) console.log(args.log);
if(args.msg) document.getElementById('viewport').innerHTML = args.msg;
};
example.process = (callback) => {
example.message({ msg: example.tokens, log: example.tokens[0] });
callback();
};
example.callback = () => {
example.message({ msg: example.tokens[1], log: example.tokens[1] });
};
example.init = () => {
example.process(example.callback);
};
document.addEventListener('DOMContentLoaded',example.init);