Skip to content

Instantly share code, notes, and snippets.

@aclave1
Created March 6, 2020 05:28
Show Gist options
  • Save aclave1/9670b93d7981d94df1ad11accc3bf69a to your computer and use it in GitHub Desktop.
Save aclave1/9670b93d7981d94df1ad11accc3bf69a to your computer and use it in GitHub Desktop.
recursion example for a friend
// example 1
x();
function x() {
console.log('hello!')
x();
}
//example 2
print_multiple_times(10)
function print_multiple_times(remaining) {
if (remaining=== 0) {
console.log('done')
return;
}
console.log('hello!')
print_multiple_times(remaining - 1)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment