Output HTML with if/then Javascript?

Viewed 57

The following javascript works but I want to replace the words "YOUTUBE" with a font awesome icon. The variable "type" will either be YOUTUBE or VIMEO or SOUNDCLOUD, so I am trying to incorporate a JS if/then statement in the middle of the spaghetti...

This is the code:

playlistHtml  += "<li>"+val.sources[0].type+" Song Name Here</li>"

This is the output:

YOUTUBE Song Name Here

playlistHtml  += "<li><div id='logo'></div>"+
   if (val.sources[0].type == "YOUTUBE") 
   {
      document.getElementById('logo').innerHTML = "<i class='fa fa-youtube-play' aria-hidden='true'></i> Song Name Here</li>";});

Any help is appreciated...

2 Answers
Related