Skip to content

Instantly share code, notes, and snippets.

@lupos
Created December 9, 2015 00:59
Show Gist options
  • Select an option

  • Save lupos/8eed7eaa5741bdd1242a to your computer and use it in GitHub Desktop.

Select an option

Save lupos/8eed7eaa5741bdd1242a to your computer and use it in GitHub Desktop.
console.log("Linked.");
// Dramatis Personae
var hobbits = [
'Frodo Baggins',
'Samwise \'Sam\' Gamgee',
'Meriadoc \'Merry\' Brandybuck',
'Peregrin \'Pippin\' Took'
];
var buddies = [
'Gandalf the Grey',
'Legolas',
'Gimli',
'Strider',
'Boromir'
];
var lands = ['The Shire', 'Rivendell', 'Mordor'];
var body = document.querySelector('body');
// 1 __________________________________________
var makeMiddleEarth = function(){
// create a section tag with an id of middle-earth
var secMiddleEarth = document.createElement("section");
secMiddleEarth.id = "middle-earth";
console.log(secMiddleEarth);
// add each land as an article tag
for ( var i = 0; i < lands.length; i++ ) {
//create article tag
var land = document.createElement("article");
// <article></article>
console.log(land);
// inside each article tag include an h1 with the name of each land
var header = document.createElement("h1");
//<h1></h1>
console.log(header);
//insert name of land in h1
header.innerHtml = lands[i];
//<h1>land name</h1>
console.log(header.innerHtml);
// insert h1 into land
land.appendChild(header);
// <article><h1>land name</h1></article>
console.log(land);
secMiddleEarth.appendChild( land );
}
// append middle-earth to your document body
body.appendChild( secMiddleEarth );
}
makeMiddleEarth();
// 2 __________________________________________
var makeHobbits = function(){
// display an unordered list of hobbits in the shire (which is the second article tag on the page)
// give each hobbit a class of hobbit
}
// 3 __________________________________________
var keepItSecretKeepItSafe = function(){
// create a div with an id of 'the-ring'
// give the div a class of 'magic-imbued-jewelry'
// add the ring as a child of Frodo
}
// 4 __________________________________________
var makeBuddies = function(){
// create an aside tag
// attach an unordered list of the 'buddies' in the aside
// insert your aside as a child element of rivendell
}
// 5 __________________________________________
var beautifulStranger = function(){
// change the 'Strider' textnode to 'Aragorn'
}
// 6 ___________________________________________
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment