Skip to content

Instantly share code, notes, and snippets.

@otkrsk
Last active February 20, 2020 01:15
Show Gist options
  • Save otkrsk/cf7e86792b212f4ae105eda453e61b71 to your computer and use it in GitHub Desktop.
Save otkrsk/cf7e86792b212f4ae105eda453e61b71 to your computer and use it in GitHub Desktop.
Possible technique for recursive functions
const createDivs = howMany => {
  if (!howMany) return;
  document.body.insertAdjacentHTML("beforeend", "<div></div>");
  return createDivs(howMany - 1);
};
createDivs(5);
public function thisIsRecursive($x) {
  if(!$x) return;
  print $x + $x;
  thisIsRecursive($x -1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment