[JavaScript] String Builder
javascript\nvar decodeCiphertext = function(encodedText, rows) {\n    const numColumns = encodedText.length / rows;\n    const stringBuilder = [];\n    let next
```javascript\nvar decodeCiphertext = function(encodedText, rows) {\n    const numColumns = encodedText.length / rows;\n    const stringBuilder = [];\n    let nextCol = 1;\n    let row = 0;\n    let col = 0;\n    let index = 0\n    while (index < encodedText.length) {\n        stringBuilder.push(encodedText[index]);\n        if (row === rows - 1 || col === numColumns - 1) {\n            row = 0;\n            col = nextCol;\n            nextCol++;\n        } else {\n            row++;\n            col++;\n        }\n        index = calcIndex(row, col, numColumns);\n    }\n    while (stringBuilder[stringBuilder.length - 1] === \' \') {\n        stringBuilder.pop();\n    }\n    return stringBuilder.join(\'\');\n};\n\nfunction calcIndex(row, col, numColumns) {\n    return row * numColumns + col;\n}\n```
['String', 'JavaScript']