MediumPro challengePythonJavaScriptTypeScript

Base64 Encode

Node.jsEncodingBuffers

Encode an array of bytes (0–255) into a Base64 string.

solve([77, 97, 110])'TWFu'. Pad with = to a length multiple of 4.

Sample tests

Test #1Three bytes "Man"
Input: [[77,97,110]]
Output: "TWFu"
Test #2Two bytes pad with =
Input: [[77,97]]
Output: "TWE="
Test #3One byte pad with ==
Input: [[77]]
Output: "TQ=="
Test #4Empty input
Input: [[]]
Output: ""
Test #5"Hi"
Input: [[72,105]]
Output: "SGk="