JavaScript
https://leetcode.com/problems/determine-if-string-halves-are-alike/
function halvesAreAlike(str){
let volwes=['a','i','e','o','u','A','I','E','O','U']
let a=str.slice(0,str.length/2)
let b=str.slice(str.length/2)
let count1=0, count2=0
for(let aelement of a){
if(volwes.includes(aelement)){
count1++
}
}
for(let belement of b){
if(volwes.includes(belement)){
count2++
}
}
return count1===count2
}
console.log(halvesAreAlike('AbCdEfGh'))
let volwes=['a','i','e','o','u','A','I','E','O','U']
let a=str.slice(0,str.length/2)
let b=str.slice(str.length/2)
let count1=0, count2=0
for(let aelement of a){
if(volwes.includes(aelement)){
count1++
}
}
for(let belement of b){
if(volwes.includes(belement)){
count2++
}
}
return count1===count2
}
console.log(halvesAreAlike('AbCdEfGh'))
Variantlar
Anonymous Quiz
46%
11,13,2,14
24%
11,13,2
23%
SyntaxError:Illegal break statement
8%
undefined