DEV Community

Discussion on: 5 easy wins to refactor even the ugliest code

Collapse
 
jriceindustries profile image
John • Edited

Number 5 - assign track.getGenre() to a string once at the beginning and compare to that variable.

var genre = track.getGenre();
if (genre == "jazz"){}
...

No need to run the overhead of whatever logic is involved in getGenre() in each if.

Collapse
 
mlevkov profile image
Mikhail Levkovsky

good call! thanks for spotting it :)