-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Completed Practice DOM/Fetch Challenges #13
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work!
function sortBreeds() { | ||
let select = document.getElementById('breed-dropdown') | ||
select.addEventListener('change', () => { | ||
dogList.innerText = '' | ||
let letter = select.value | ||
|
||
for(const dogBreed in dogObj) { | ||
if(dogBreed[0] === letter) { | ||
let li = document.createElement('li') | ||
li.innerText = dogBreed | ||
dogList.appendChild(li) | ||
li.addEventListener('click', () => { | ||
li.style.color = 'green' | ||
}) | ||
} | ||
} | ||
}) | ||
} | ||
} sortBreeds() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is definitely a cool way of doing this, but to make it more readable you could make the dogObj
globally available and extract this function. That would make the code more readable and easier to follow.
Practiced accessing information from the dog API and using it to update the DOM. Also practiced listening for user events and updating the DOM in response.