Skip to content
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
41 changes: 38 additions & 3 deletions exercises.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
* ie: "cat" => "tac"
*/

var firstReverse = function(str) {
if (typeof str != 'string') {
return null;
}else{
return str.split('').reverse().join('');
}
};

/** Function: alphaOrder
* The function will take the str parameter being passed in and
* return the string in alphabetical order
Expand All @@ -14,6 +22,14 @@
* ie: "cake" => "acek"
*/

var alphaOrder = function(str) {
if (typeof str === 'string') {
return str.split('').sort().join('');
}else{
return null;
}
};

/** Function: vowelCount
* The function will take the str parameter being passed in and
* return the number of vowels in the string
Expand All @@ -22,6 +38,21 @@
* ie: "oreo" => 3
*/

var vowelCount = function(str) {
var vowels = ['a', 'A', 'e', 'E', 'i', 'I', 'o', 'O', 'u', 'U'];
var count = 0

if (typeof str === 'string') {
for (var i = 0; i < str.length; i++) {
if (vowels.indexOf(str[i])) {
count++
}
}
return count;
}

}

/** Function: timeConvert
* The function will take the str parameter representing the amount of minutes being passed in and
* return the number of hours and minutes. Seperate the number of hours
Expand All @@ -31,6 +62,10 @@
* ie: 68 => 1:8
*/

var timeConvert = function(str) {

}

/** Function: repeatString
* The function will take in two parameters and repeat a given string (first argument)
* num times (second argument). Return an empty string if num is a negative number
Expand All @@ -56,9 +91,9 @@
*/

module.exports = {
firstReverse: null,
alphaOrder: null,
vowelCount: null,
firstReverse: firstReverse,
alphaOrder: alphaOrder,
vowelCount: vowelCount,
timeConvert: null,
repeatString: null
}
Loading