Created
June 30, 2017 23:51
-
-
Save venomnert/c921cb1d3e8f484cffc23f8185400a9f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const schools = [ | |
{ name: "St. Marcellinus Secondary School", address: "730 Courtneypark Drive West" }, | |
{ name: "Sir William Mulock S.S.", address: "705 Columbus Way" }, | |
{ name: "George Harvey Collegiate Institute", address: "1700 Keele St" }, | |
{ name: "Dr. G.W. Williams S.S.", address: "39 Dunning Ave." }, | |
{ name: "Weston Collegiate Institute", address: "100 Pine St" } | |
]; | |
const _pipe = (a, b) => (arg) => b(a(arg)); | |
const pipe = (...ops) => ops.reduce(_pipe); | |
//1. Iterate over the array of schools | |
//2. Make a li element containing the school name and address separated by '-' | |
//3. Append the li to the ul with an id of 'school-list' | |
const makeLi = (schoolObj) => { | |
const newLI = document.createElement('li'); | |
newLI.appendChild(document.createTextNode(`${schoolObj.name} - ${schoolObj.address}`)); | |
return newLI | |
} | |
const appendLiToSchoolList = (li) => { | |
let schoolList = document.querySelector('#school-list'); | |
return schoolList.appendChild(li); | |
} | |
const generateLi = pipe(makeLi,appendLiToSchoolList); | |
schools.forEach(school => generateLi(school)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment