Created
May 18, 2018 21:47
-
-
Save CheezItMan/fef777a8edd85a1c57bfa5fbb9d9c7b2 to your computer and use it in GitHub Desktop.
Solution for the ada pets exercise
This file contains hidden or 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
// let target = document.getElementById('js-lecture-target'); | |
// | |
// target.innerHTML = '<p>content!</p>'; | |
$(document).ready(() => { | |
const pets = [ | |
{ | |
name: 'kylo', species: 'dog', human: 'kari', mammal: true | |
}, | |
{ | |
name: 'gecky', species: 'lizard', human: 'dan', mammal: false | |
}, | |
{ | |
name: 'hedwig', species: 'owl', human: 'harry', mammal: false | |
}, | |
{ | |
name: 'crookshanks', species: 'cat', human: 'hermione', mammal: true | |
}, | |
{ | |
name: 'scabbers', species: 'rat', human: 'ron', mammal: true | |
}, | |
]; | |
$('#js-lecture-target').append('<table></table>'); | |
$('#js-lecture-target table').append('<tr><th>Name</th><th>Species</th><th>Human</th></tr>'); | |
pets.forEach((pet) => { | |
const tableRow = | |
`<tr class="${pet.mammal ? "mammal": "nonmammal"}"> | |
<td>${pet.name}</td><td>${pet.species}</td><td>${pet.human}</td> | |
</tr>`; | |
$('#js-lecture-target table').append(tableRow); | |
}); | |
// $('#js-lecture-target').append('<h2>This is great!</h2>') | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment