Functions Recap
function defineJellyBean(colour, flavour, scent) {
var jellyBean = {
color: colour,
flavor: flavour,
scent: scent
}
return jellyBean;
};
var beth = defineJellyBean('aquamarine', 'elderberry', 'blueberries');
var vic = defineJellyBean('pink-green', 'watermelon', 'watermelon');
var darthVader = defineJellyBean('light/dark green', 'pear', 'pear');
var crazyPerson = defineJellyBean('yellow and white spotted', 'popcorn', 'dry erase marker');
Real World Example: DOM
function createDomElement(tagName, content) {
var domElement;
domElement = document.createElement(tagName);
domElement.innerHTML = content;
return domElement;
}
var fakeNewsArticle = createDomElement('article', 'In news today, Billy Corgan came to WDI and named himself Scott.');