From fe18bd084c4a03d7d950cc7061755ad08cdc7994 Mon Sep 17 00:00:00 2001 From: Cayla Horsey Date: Tue, 21 May 2024 10:04:00 -0400 Subject: [PATCH 1/4] Pass first 3 challenges --- src/index.js | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 407dde1c..247f1743 100644 --- a/src/index.js +++ b/src/index.js @@ -1 +1,62 @@ -console.log('%c HI', 'color: firebrick') +document.addEventListener('DOMContentLoaded', function() { + const imgUrl = "https://dog.ceo/api/breeds/image/random/4"; + const breedUrl = "https://dog.ceo/api/breeds/list/all"; + let dogList = document.getElementById('dog-breeds') + let dogContainer = document.getElementById('dog-image-container') + + + + + fetch(imgUrl) + .then(res => res.json()) + .then(dogs => { + let dogPics = Object.entries(dogs.message) + + dogPics.forEach(dog => { + let img = document.createElement('img') + img.src = dog[1] + + dogContainer.appendChild(img) + }) + }) + + fetch(breedUrl) + .then(res => res.json()) + .then(dogBreed => { + let dogObj = dogBreed.message + for(const dog in dogObj){ + let li = document.createElement('li') + + li.innerText = dog + dogList.appendChild(li) + + li.addEventListener('click', (e) => { + li.style.color = 'green' + }) + + // console.log(dog[0]) + + let select = document.getElementById('breed-dropdown') + + select.addEventListener('change', (e) => { + dogList.innerText = '' + let letter = select.value + + for(const dog in dogObj) { + if(dog[0] === letter) { + let li = document.createElement('li') + li.innerText = dog + dogList.appendChild(li) + } + } + }) + + //Grab select ID + //Target value / letter + //If selection letter === dog[0] + //clear UL innerHTML + //Re-add for breeds whos dog[0] === selection letter + } + }) +}) + From 82e44a2cc8ae5b062872b6782e010ee186e26320 Mon Sep 17 00:00:00 2001 From: Cayla Horsey Date: Tue, 21 May 2024 10:26:31 -0400 Subject: [PATCH 2/4] Add more drop down option --- index.html | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/index.html b/index.html index 3ab6615e..5d41c102 100644 --- a/index.html +++ b/index.html @@ -19,6 +19,29 @@

Dog CEO

+ + + + + + + + + + + + + + + + + + + + + + +