I'm using a large API that contains a JSON file of TV Show information.
The key 'name' contains guest information. Most of them return with the list of guests, however some return as 'Episode [x]'. For example:
for (x in data){
let title = data[x]._embedded.show.name;
let guests = data[x].name;
let airdate = data[x].airdate;
switch(title){
// ...
case 'The Daily Show with Trevor Noah':
p.innerHTML = airdate + " " + guests;
noah.appendChild(p);
console.log(airdate, guests);
break;
default:
break;
}
}
Guest values return as:
Kevin Young, Antoinette Robertson, Gen. Michael Hayden, David Blaine, Episode 63, Episode 64, Episode 65
I'd like to display just the names, and somehow remove any instance of 'Episode'. I have a few ideas, but I'm new to JavaScript and having some trouble. If more code is necessary to answer this question, I'll update this question. Thanks in advance
If code is necessary to answer this question, I'll update this with necessary information.Yes, always post the code you've tried with your question if you want help debugging it.switch(title){is returned by a JSON call... Rather a valid JSON.