diff --git a/03_recursion/ES6/01_countdown.js b/03_recursion/ES6/01_countdown.js index 4641887..b9a22f6 100644 --- a/03_recursion/ES6/01_countdown.js +++ b/03_recursion/ES6/01_countdown.js @@ -1,10 +1,11 @@ +/** + * Countdown + * @param {number} i Number + */ const countdown = i => { console.log(i); // base case - if (i <= 0) { - return; - } - + if (i <= 0) return; countdown(i - 1); }; diff --git a/03_recursion/ES6/02_greet.js b/03_recursion/ES6/02_greet.js index ffec669..b658743 100644 --- a/03_recursion/ES6/02_greet.js +++ b/03_recursion/ES6/02_greet.js @@ -1,12 +1,23 @@ +/** + * Displays a message to the console + * @param {string} name Name + */ const greet2 = name => console.log(`how are you, ${name}?`); -const bye = () => console.log('ok bye!'); +/** + * Displays a message to the console + */ +const bye = () => console.log("ok bye!"); -const greet = (name) => { +/** + * Displays a message to the console + * @param {string} name Name + */ +const greet = name => { console.log(`hello, ${name}!`); greet2(name); - console.log('getting ready to say bye...'); + console.log("getting ready to say bye..."); bye(); }; -greet('adit'); +greet("adit"); diff --git a/03_recursion/ES6/03_factorial.js b/03_recursion/ES6/03_factorial.js index 022a61d..74fa4dd 100644 --- a/03_recursion/ES6/03_factorial.js +++ b/03_recursion/ES6/03_factorial.js @@ -1,7 +1,10 @@ -const fact = (x) => { - if (x === 1) { - return 1; - } +/** + * Consider the factorial of the number + * @param {number} x Number + * @returns {number} Result + */ +const fact = x => { + if (x === 1) return 1; return x * fact(x - 1); }; diff --git a/03_recursion/javascript/01_countdown.js b/03_recursion/javascript/01_countdown.js index 529d1c8..e4208c9 100644 --- a/03_recursion/javascript/01_countdown.js +++ b/03_recursion/javascript/01_countdown.js @@ -1,10 +1,11 @@ +/** + * Countdown + * @param {number} i Number + */ function countdown(i) { console.log(i); // base case - if (i <= 0) { - return; - } - + if (i <= 0) return; countdown(i - 1); } diff --git a/03_recursion/javascript/02_greet.js b/03_recursion/javascript/02_greet.js index 5161a08..54ec5fd 100644 --- a/03_recursion/javascript/02_greet.js +++ b/03_recursion/javascript/02_greet.js @@ -1,16 +1,27 @@ +/** + * Displays a message to the console + * @param {string} name Name + */ function greet2(name) { - console.log('how are you, ' + name + '?'); + console.log("how are you, " + name + "?"); } +/** + * Displays a message to the console + */ function bye() { - console.log('ok bye!'); + console.log("ok bye!"); } +/** + * Displays a message to the console + * @param {string} name Name + */ function greet(name) { - console.log('hello, ' + name + '!'); + console.log("hello, " + name + "!"); greet2(name); - console.log('getting ready to say bye...'); + console.log("getting ready to say bye..."); bye(); } -greet('adit'); +greet("adit"); diff --git a/03_recursion/javascript/03_factorial.js b/03_recursion/javascript/03_factorial.js index 89b8ab7..76d46e4 100644 --- a/03_recursion/javascript/03_factorial.js +++ b/03_recursion/javascript/03_factorial.js @@ -1,7 +1,10 @@ +/** + * Consider the factorial of the number + * @param {number} x Number + * @returns {number} Result + */ function fact(x) { - if (x === 1) { - return 1; - } + if (x === 1) return 1; return x * fact(x - 1); }