File tree Expand file tree Collapse file tree 4 files changed +12
-9
lines changed
Expand file tree Collapse file tree 4 files changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -25,8 +25,10 @@ function recursiveFunction(params) {
2525Common Use Cases
2626Recursive functions are often used to solve problems that can be divided into smaller, similar subproblems. Here are some common use cases:
2727
28- 1 . Calculating Factorials
28+ 1 . Calculating Factorials:
29+
2930A recursive function can be used to calculate the factorial of a number.
31+
3032``` javascript
3133function factorial (n ) {
3234 if (n === 0 ) {
@@ -38,8 +40,9 @@ function factorial(n) {
3840
3941factorial (5 ); // Returns 120
4042```
41- 2 . Fibonacci Sequence
43+ 2 . Fibonacci Sequence:
4244The Fibonacci sequence can be calculated using recursion.
45+
4346``` javascript
4447function fibonacci (n ) {
4548 if (n <= 1 ) {
Original file line number Diff line number Diff line change @@ -19,4 +19,5 @@ for (let i = 1; i <= 5; i++) {
1919 }
2020 console .log (` Current value of i: ${ i} ` );
2121}
22+ ```
2223
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ pageNumber: 36
44---
55# Split
66
7- The split() method divides a string into a list of substrings and returns them as an array.
7+ The ` split() ` method divides a string into a list of substrings and returns them as an array.
88* using the ` split() ` method
99* using the template literal (introduced in ES6)
1010
Original file line number Diff line number Diff line change @@ -8,19 +8,18 @@ The `string.substring()` is an inbuilt function in JavaScript that is used to re
88
99Syntax:
1010
11- string.substring(Startindex, Endindex)
11+ ` string.substring(StartIndex, EndIndex) `
1212
1313# Syntax:
1414
15- * str.substr(start , length)
16-
15+ * using ` str.substr(start , length) `
1716* using the ` substr() ` method
1817* using the template literal (introduced in ES6)
1918
20- The substr() method takes in:
19+ The ` substr() ` method takes in:
2120
22- Parameters: Here the Startindex and Endindex describe the part of the string to be taken as a substring. Here the Endindex is optional.
23- Return value: It returns a new string that is part of the given string. JavaScript code to show the working of string.substring() function:
21+ Parameters: Here the StartIndex and EndIndex describe the part of the string to be taken as a substring. Here, the EndIndex is optional.
22+ Return value: It returns a new string that is part of the given string. JavaScript code to show the working of ` string.substring() ` function:
2423
2524``` javascript
2625// Example 1:
You can’t perform that action at this time.
0 commit comments