File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -198,6 +198,19 @@ function longestCommonString(){
198198 return arr[0].substring(0,i)
199199}
200200longestCommonString()
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================================================================================================================================================================================
202215Code 17: To find vowels and its count in a given string
203216function vowelCounts(){
You can’t perform that action at this time.
0 commit comments