Skip to content

Instantly share code, notes, and snippets.

@craigayre
Last active June 11, 2017 13:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save craigayre/c1bc2abbb9335e46c567bb931e6f05af to your computer and use it in GitHub Desktop.
Save craigayre/c1bc2abbb9335e46c567bb931e6f05af to your computer and use it in GitHub Desktop.
d=>{for(a=e=b=0,c='';a<((4*d.length+2)/3|0);c+=`${x='ABCDEFGHIJKLMNOPQRSTUVWXYZ'}${x.toLowerCase()}0123456789+/`[b>>2*(++a&3)&63])a&3^3&&(b=b<<8^d[e++]);while(a++&3)c+="=";return c}
@craigayre
Copy link
Author

Add initial solution

@craigayre
Copy link
Author

Use arrow function notation

@craigayre
Copy link
Author

Use template literals for lowercase alphabet

@craigayre
Copy link
Author

Use default parameters when assigning a - removes semicolon

@craigayre
Copy link
Author

Remove args as parameters since they're assigned inside first for loop. Move c assignment so that parens aren't needed for arrow function since only one param

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment