141. implement btoa()
Share
easy - accepted / - tried
btoa() accepts a binary string and returns a Base64-encoded ASCII string from it. Characters in a binary string are the ASCII character for each byte of the binary data.
Please read Base64 wiki and implement your own btoa()
.
myBtoa('BFE')// 'QkZF'myBtoa('BFE.dev')// 'QkZFLmRldg=='
note
- Please don't use
window.btoa()
in your code. - The binary string passed to your function are all valid ASCII characters, there will be another problem on the general Base64 encoding/decoding.