Skip to content

Commit c9da137

Browse files
authored
Update js codes.docx
1 parent a06f834 commit c9da137

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

js codes.docx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,19 @@ function longestCommonString(){
198198
return arr[0].substring(0,i)
199199
}
200200
longestCommonString()
201+
--------------------------------------------------------------------
202+
function longestCommonString(){
203+
let array=["go","google","gosh"]
204+
var arr = array.sort((a,b)=>a.length-b.length)
205+
let result =""
206+
for(let i=0; i<arr[0].length; i++){
207+
if(arr[0][i]===arr[arr.length-1][i]){
208+
result+=arr[0][i]
209+
}
210+
}
211+
return result
212+
}
213+
console.log(longestCommonString())
201214
================================================================================================================================================================================
202215
Code 17: To find vowels and its count in a given string
203216
function vowelCounts(){

0 commit comments

Comments
 (0)