Created
September 24, 2021 05:27
-
-
Save blacksheep557/5578c12c528a6322c9bea311ff11b3e4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function fold(arr) { | |
| let start = 0; | |
| let end = arr.length - 1; | |
| const res = [] | |
| while (start < end) { | |
| res.push(arr[start] + arr[end]); | |
| start++; | |
| end--; | |
| } | |
| if (arr.length % 2 === 1) res.push(arr[start]) | |
| return res; | |
| } | |
| function foldArray(arr, x) { | |
| for (let i = 0; i< x; i++){ | |
| arr = fold(arr) | |
| } | |
| console.log(arr) | |
| return arr | |
| } | |
| function calculate(string) { | |
| const arr = string.split(/(?=[A-Z])/); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment