FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
JavaScript-II-Mini/recursion.js at master · bloominstituteoftechnology/JavaScript-II-Mini · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
bloominstituteoftechnology
/
JavaScript-II-Mini
Public
Notifications
You must be signed in to change notification settings
Fork
210
Star
2
Code
Issues
0
Pull requests
67
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
JavaScript-II-Mini
/
recursion.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
33 lines (24 loc) · 732 Bytes
Breadcrumbs
JavaScript-II-Mini
/
recursion.js
Copy path
File metadata and controls
33 lines (24 loc) · 732 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// to test these problems you can run 'node recursion.js' in your terminal
// Problem 1:
let
n
=
1
;
while
(
n
<=
10
)
{
console
.
log
(
'While Loop'
,
n
)
;
n
++
;
}
// write a recursive - function called countToTen that mimics the while loop above.
// code here
// when you code is ready, un-comment the next line and run the file
// console.log(countToTen());
/* ================ Next Problem ================= */
// Problem 2:
const
factorial
=
n
=>
{
let
result
=
1
;
for
(
let
i
=
2
;
i
<=
n
;
i
++
)
{
result
*=
i
;
}
return
result
;
}
;
console
.
log
(
factorial
(
5
)
)
;
// write the above function in a recursive way.
// when your code is ready, un-comment the next line and run the file
// console.log(recursiveFactorial());
Back
|
FazBrowse Home
|
New Git URL