Skip to content

Commit a17a4e0

Browse files
authored
Merge pull request #5 from RohitPaul0007/main-4
Update ReverseString.js
2 parents 60b0656 + b85f26c commit a17a4e0

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

ReverseString.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1-
var string = 'Riya kumari is a nice girl'
1+
let string = 'Riya kumari is a nice girl'
22

3-
var reverseEntireSentence = reverseBySeparator(string, "");
4-
var reverseEachWord = reverseBySeparator(reverseEntireSentence, " ");
3+
let reverseEntireSentence = reverseBySeparator(string, "");
4+
let reverseEachWord = reverseBySeparator(reverseEntireSentence, " ");
5+
/* As a general rule, you should always declare variables with const,
6+
if you realize that the value of the variable needs to change, go back and change it to let.
7+
Use let when you know that the value of a variable will change.
8+
Use const for every other variable. Do not use var.*/
59

610
console.log(reverseEntireSentence);
711
console.log(reverseEachWord);
812

913
function reverseBySeparator(string, separator) {
1014
return string.split(separator).reverse().join(separator);
11-
}
15+
}

0 commit comments

Comments
 (0)