Ad
Algorithms
Logic
Fundamentals

Save 1 byte on the boolean logic. Expected to save more, but oh well... !a&&!b&&!c ==> !(a||b||c)

Combine two isNaNs together.

Why do we need dash between 333 444 555 etc.?

Save on long method names

Code
Diff
  • validateKey=(k,s=k.split('-'))=>k[l='length']+s[0][l]==14&&!(isNaN(s[0]+s[1])||'333444555666777888999'[i='includes'](s[0])||s[1]%7!=0||'089'[i](k[k[l]-1]))
    • validateKey=(k,s=k.split('-'))=>k.length+s[0].length==14&&!isNaN(s[0])&&!isNaN(s[1])&&!'333-444-555-666-777-888-999'.includes(s[0])&&s[1]%7==0&&!'089'.includes(k.slice(-1))
    • validateKey=(k,s=k.split('-'))=>k[l='length']+s[0][l]==14&&!(isNaN(s[0]+s[1])||'333444555666777888999'[i='includes'](s[0])||s[1]%7!=0||'089'[i](k[k[l]-1]))