JB4GDI / awsfaviconupdater

IAM shouldn't be the only tab with a unique favicon! This Chrome Extension sets favicons for many AWS services, so your tabs make more sense.
33 stars 8 forks source link

Simplify conditional statements #1

Closed openam closed 4 years ago

openam commented 5 years ago

FYI I'm guessing that when you typed awsService == 'cloudsearch' || 'swf' you really meant awsServiceName === 'cloudsearch' || awsServiceName === 'swf'. The || 'swf' would always return true as you found out. Strings are truthy, unless it's an empty string, e.g. ''.

openam commented 5 years ago

@JB4GDI awsService === 'cloudsearch' || awsService === 'swf' will never be true now, because let awsService = awsServiceName + ".png";

This get rid of having to have if statement by just finding the element or creating a new one.

document.querySelector("link[rel*='icon']") will find either rel === 'icon' or rel === 'shortut icon'