@@ -30,7 +30,7 @@ You are given a variable celsius representing a temperature in Celsius. Use the
30
30
31
31
### Solution
32
32
33
- ```
33
+ ``` js
34
34
function convertToF (celsius ) {
35
35
let fahrenheit = (celsius * 9 ) / 5 + 32 ;
36
36
return fahrenheit;
@@ -53,7 +53,7 @@ Your result must be a string.
53
53
54
54
### Solution 1
55
55
56
- ```
56
+ ``` js
57
57
function reverseString (str ) {
58
58
return str .split (" " ).reverse ().join (" " );
59
59
}
@@ -63,7 +63,7 @@ reverseString("hello");
63
63
64
64
### Solution 2
65
65
66
- ```
66
+ ``` js
67
67
function reverseString (str ) {
68
68
let reversedString = " " ;
69
69
for (let i = str .length - 1 ; i >= 0 ; i-- ) {
@@ -73,7 +73,6 @@ function reverseString(str) {
73
73
}
74
74
75
75
reverseString (" hello" );
76
-
77
76
```
78
77
79
78
### 3. Factorialize a Number
@@ -94,20 +93,19 @@ Only integers greater than or equal to zero will be supplied to the function.
94
93
95
94
### Solution 1
96
95
97
- ```
96
+ ``` js
98
97
function factorialize (num ) {
99
98
if (num === 0 ) {
100
99
return 1 ;
101
100
} else return num * factorialize (num - 1 );
102
101
}
103
102
104
103
factorialize (5 );
105
-
106
104
```
107
105
108
106
### Solution 2
109
107
110
- ```
108
+ ``` js
111
109
function factorialize (num ) {
112
110
let factorializedNumber = 1 ;
113
111
for (let i = 2 ; i <= num; i++ ) {
@@ -117,8 +115,6 @@ function factorialize(num) {
117
115
}
118
116
119
117
factorialize (5 );
120
-
121
-
122
118
```
123
119
124
120
### 4. Find the Longest Word in a String
@@ -131,9 +127,9 @@ Your response should be a number.
131
127
132
128
---
133
129
134
- ### Solution 1
130
+ ### Solution
135
131
136
- ```
132
+ ``` js
137
133
function findLongestWordLength (str ) {
138
134
let splitWords = str .split (" " );
139
135
let longestWordLength = 0 ;
@@ -147,5 +143,4 @@ function findLongestWordLength(str) {
147
143
}
148
144
149
145
findLongestWordLength (" The quick brown fox jumped over the lazy dog" );
150
-
151
146
```
0 commit comments