Skip to content

Instantly share code, notes, and snippets.

@lienista
Last active August 28, 2018 04:06
Show Gist options
  • Select an option

  • Save lienista/a77360f195ee13ea8f688dd2eb7f24ec to your computer and use it in GitHub Desktop.

Select an option

Save lienista/a77360f195ee13ea8f688dd2eb7f24ec to your computer and use it in GitHub Desktop.
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