* Separates string into chunks of the same size * * @param {string} str - string to separate into chunks * @param {int} size - number of characters wanted in each chunk * @return {array} - array of original string split into chunks * * @example * chunkify("this is a test", 2)
(str, size)
| 37 | * chunkify("this is a test", 2) |
| 38 | */ |
| 39 | function chunkify(str, size) { |
| 40 | const chunks = [] |
| 41 | for (let i = 0; i < str.length; i += size) { |
| 42 | chunks.push(str.slice(i, i + size)) |
| 43 | } |
| 44 | return chunks |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Rotates string representation of bits to the left |