Skip to content

Commit 4bcab83

Browse files
authored
Update js codes.docx
1 parent c22117d commit 4bcab83

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

js codes.docx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,21 @@ function removeDuplicates(){
3737
}
3838
console.log(removeDuplicates())
3939
output = "aidnI si ym yrtnuoc"
40+
------------------------------------------
41+
var reverseWords = function(s) {
42+
let res = '';
43+
let word = '';
44+
for (let c of s) {
45+
if (c === ' ') {
46+
res += word + c;
47+
word = '';
48+
} else {
49+
word = c + word;
50+
}
51+
}
52+
return res + word;
53+
};
54+
console.log(reverseWords("priya bagde"))
4055
================================================================================================================================================================================
4156
Code 5:String reverse with reversing of individual words
4257
function withoutReverse(){

0 commit comments

Comments
 (0)