Created
June 8, 2018 14:33
-
-
Save chriskchew/d34d824576555a2fc4d4a880286f1916 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
// 1. What does this function do? How would you call it? | |
function doWork(a) { | |
return function(b) { | |
return a + b; | |
} | |
} | |
// 2. What does this function do? How would you call it? | |
function doWork(id) { | |
return fetch(`http://somewhere.com/book/${id}`) | |
.then(response => { | |
return response.json(); | |
}) | |
.then(json => { | |
return json.author; | |
}); | |
} | |
// 3. What does this function do? If you were asked to provide comments on this code (like in a code review), | |
// what would you comment on? | |
function setupClickHandlers() { | |
var x = document.querySelectorAll('.list-item'); | |
for (var i = 0; i < x.length; i++){ | |
var x1 = x[i]; | |
x1.onclick = function(evt) { | |
var ET = evt.target; | |
if(ET.className.indexOf('active') != -1) { | |
ET.className = 'list-item'; | |
} else { | |
ET.className = 'list-item active'; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment