Last active
August 28, 2018 04:07
-
-
Save lienista/c4344bf80b7009ea7c4798a3dcb26364 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
| const recursiveMultiplier = (arr, num) => { | |
| let newArray = []; | |
| let mult = function(a) { | |
| if(a.length) { | |
| newArray[a.length-1] = a.pop()*num; | |
| mult(a); | |
| return newArray; | |
| } | |
| return; | |
| } | |
| return mult(arr); | |
| } | |
| let x = [1, 2, 3], num = 2; | |
| let y = recursiveMultiplier(x,num); | |
| console.log(y); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment