Learning Javascript (…again)

Photo by Claudio Schwarz on Unsplash
class GenreServices {constructor(baseUrl){this.baseUrl = baseUrl;};getGenres() {fetch(this.baseUrl) .then(resp => resp.json()) .then(genres => {console.log(genres)genres.forEach(genre => {const newGenre = new Genre(genre)newGenre.renderGenre();})})};};
class Genre {constructor({id, name}) {this.id = id;this.name = name; }}
class Genre {constructor({id, name}) {this.id = id;this.name = name;}renderGenre() {const genreSelect = document.getElementById('genre-menu');const genreCard = document.createElement('option');
genreCard.text = this.namegenreCard.value = this.id;genreSelect.appendChild(genreCard);};};
<form id="album-form"><input type="text" id="title" name="title" placeholder="Album Title" /><input type="text" id="artist" name="artist" placeholder="Artist" /><input type="text" id="year" name="year" placeholder="Year Released" />
<select id="genre-menu" name="genre-menu"><option value="">Select Genre:</option></select>
<button type="submit"> Create Album </button></form>



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Melissa Guachun

Software Developer and visual artist based in NYC. Join me on my journey to coding enlightenment or a torrential mental breakdown, whichever comes first.