You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+8-2Lines changed: 8 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,8 @@
2
2
3
3
This list showcases some of the most popular JavaScript algorithms, from simple string manipulations to classic recursive solutions and efficient searching techniques. Each snippet demonstrates a fundamental concept often encountered in coding interviews and real-world development.
4
4
5
+
> **Note:** Popularity is based on common interview topics, educational resources, and usage in developer communities.
**Explanation**: Generates the nth Fibonacci number recursively by summing the two preceding numbers.
61
63
64
+
⚠️ **Note**: This approach has **exponential time complexity O(2<sup>n</sup>)** and is inefficient for large inputs. Consider memoization or iteration for better performance.
65
+
62
66
## 5. Factorial of a Number
63
67
64
68
```js
@@ -82,6 +86,8 @@ function isPrime(num) {
82
86
}
83
87
returntrue;
84
88
}
89
+
90
+
console.log(isPrime(7)); // Output: true
85
91
```
86
92
87
93
**Explanation**: Checks if a number is prime by testing divisibility up to its square root.
@@ -152,4 +158,4 @@ function gcd(a, b) {
152
158
console.log(gcd(48, 18)); // Output: 6
153
159
```
154
160
155
-
**Explanation:** Uses the Euclidean algorithm to compute the greatest common divisor of two numbers.
161
+
**Explanation**: Uses the Euclidean algorithm to compute the greatest common divisor of two numbers.
0 commit comments