`var country = codes[1] || '';` should do the same and we can skip one check for length.