Last active
August 25, 2018 07:24
-
-
Save mojaray2k/d4921fb076ac1daa07c44cbe8e764275 to your computer and use it in GitHub Desktop.
JS Bin// source http://jsbin.com/diqumox
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Count the number of vowels in a string using just var | |
function count(targetString){ | |
var characters = ['a', 'e', 'i', 'o', 'u']; | |
var number = 0; | |
for (var i = 0; i< targetString.length; i++){ | |
if(characters.includes(targetString[i])){ | |
number++ | |
} | |
} | |
return number; | |
} | |
console.log(count('aeiobzxceiaipbiox')); | |
// Count the number of vowels in a string using const and let | |
function count(targetString){ | |
const characters = ['a', 'e', 'i', 'o', 'u']; | |
let number = 0; | |
for (var i = 0; i< targetString.length; i++){ | |
if(characters.includes(targetString[i])){ | |
number++ | |
} | |
} | |
return number; | |
} | |
console.log(count('aeiobzxceiaipbiox')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment