Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

solve reverse string and vowels counter #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Beginner/maxRecurringChar/index-START.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ Given a string of text, find and return the most recurring character.
e.g maxRecurringChar('aabacada') // will return 'a'
*/



function maxRecurringChar(text) {
// Code goes here

}


Expand Down
2 changes: 1 addition & 1 deletion Beginner/reverseString/index-START.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ E.g reverseString('algorithms') // should return 'smhtirogla'


function reverseString(text) {
// Code goes here
return [...text].reduce((acc, char) => char + acc, '')
}


Expand Down
20 changes: 19 additions & 1 deletion Beginner/vowelsCounter/index-START.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,27 @@ Given a string of text, return the number of vowels found within the text
e.g vowelsCounter('anehizxcv') // will return 3
*/

const vowels = ['a', 'e', 'i', 'o', 'u'];

function vowelsCounter(text) {
// Code goes here
/* ITERATIVE SOLUTION */
/*
let vowelNum = 0;
for(let letter of text.toLowerCase()){
if (vowels.includes(letter)){
vowelNum++;
}
}
return vowelNum
*/
/* REGEX SOLUTION */
let matchingInstances = text.match(/[aeiou]/gi);
if(matchingInstances){
return matchingInstances.length
}else{
return 0;
}

}


Expand Down