User:Pemaksa/Modularize.js

function createLink(text,url) { var newLink = document.createElement('a'); newLink.setAttribute('href', url); newLink.appendChild(document.createTextNode(text)); return newLink; }

function createMenu { var menu = document.getElementById('menu'); var items = [ {			t:'Home', u:'index.html' },		{			t:'Sales', u:'sales.html' },		{			t:'Contact', u:'contact.html' }	];	for(var i = 0; i < items.length; i++) { var item = createLink(items.t, items.u); item.className = 'menu-item'; menu.appendChild(item); } }