Last active
August 28, 2018 04:06
-
-
Save lienista/a77360f195ee13ea8f688dd2eb7f24ec 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) { | |
| if(!arr.length) { | |
| return arr; | |
| } | |
| let lastElement = arr.pop(); | |
| recursiveMultiplier(arr, num); | |
| arr.push(lastElement*num); | |
| return 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