Skip to content

Commit 9358a97

Browse files
authored
nineth commit
1 parent c72d388 commit 9358a97

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

beginner/ex7.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Have the function firstReverse(str) take the str parameter being passed and
3+
* return the string in reversed order. For example: if the input string is
4+
* "Hello World and Coders" then your program should return the string
5+
* "sredoC dna dlroW olleH".
6+
* @param {string} str A string to be reversed
7+
* @return {string} Reversed str
8+
*/
9+
10+
function firstReverse(str) {
11+
return str.split("")
12+
.reverse()
13+
.join("");
14+
}
15+
16+
console.log(firstReverse("Hello World and Coders"));

beginner/ex8.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* Have the function firstFactorial(num) take the num parameter being passed and
3+
* return the factorial of it (e.g. if num = 4, return (4 * 3 * 2 * 1)). For the
4+
* test cases, the range will be between 1 and 18 and the input will always be
5+
* an integer.
6+
*/
7+
8+
function firstFactorial(num) {
9+
if(num === 1) {
10+
return 1;
11+
}
12+
return num * firstFactorial(num-1);
13+
}
14+
15+
console.log(firstFactorial(4));

0 commit comments

Comments
 (0)