From 7db9f71e0e5380d19b6580de471ca2317d54061e Mon Sep 17 00:00:00 2001 From: LSvekis Date: Thu, 1 Jul 2021 19:50:09 -0400 Subject: [PATCH] Create recursive functions --- Chapter 12/recursive functions | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 Chapter 12/recursive functions diff --git a/Chapter 12/recursive functions b/Chapter 12/recursive functions new file mode 100644 index 0000000..afee069 --- /dev/null +++ b/Chapter 12/recursive functions @@ -0,0 +1,19 @@ +let start = 100; +loop(start); +loop1(start); +function loop(val) { + console.log(val); + if (val < 1) { + return + } + loop(val - 1); +} + +function loop1(val) { + console.log(val); + if (val > 0) { + val--; + loop1(val); + } + return 'end'; +}