File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change
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" ) ) ;
Original file line number Diff line number Diff line change
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 ) ) ;
You can’t perform that action at this time.
0 commit comments