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
/* | |
Vowel Count * | |
* Using the JavaScript language, have the function VowelCount(str) take the str * | |
* string parameter being passed and return the number of vowels the string contains * | |
* (ie. "All cows eat grass" would return 5). Do not count y as a vowel for this * | |
* challenge. | |
*/ | |
// Split sentence into array | |
// |
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
/* | |
have the function AlphabetSoup(str) take the str string parameter being passed and return the string with the letters in alphabetical order (ie. hello becomes ehllo). Assume numbers and punctuation symbols will not be included in the string. | |
*/ | |
function AlphabetSoup(str) { | |
var strArray = str; | |
return strArray.split("").sort().join(""); | |
} |
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
/* | |
have the function LongestWord(sen) take the sen parameter being passed and return the largest word in the string. If there are two or more words that are the same length, return the first word from the string with that length. Ignore punctuation and assume sen will not be empty. | |
*/ | |
function LongestWord(sen) { | |
let longestWord = ""; | |
let sentence = sen.match(/[a-z0-9]+/gi); | |
// let sentenceArray = sentence.split(" "); | |
console.log(sentence); |
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
/* | |
Have the function TimeConvert(num) take the num parameter being passed and return the number of hours and minutes the parameter converts to (ie. if num = 63 then the output should be 1:3). Separate the number of hours and minutes with a colon. | |
Input:126 | |
Output:"2:6" | |
Input:45 | |
Output:"0:45" |
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
/* | |
have the function CheckNums(num1,num2) take both parameters being passed and return the string true if num2 is greater than num1, otherwise return the string false. If the parameter values are equal to each other then return the string -1. | |
*/ | |
function CheckNums (num1, num2) { | |
if (num2 > num1) { | |
return true; | |
} | |
else if (num1 == num2) { | |
return -1; |
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
/* | |
Have the function LetterCapitalize(str) take the str parameter being passed and capitalize the first letter of each word. Words will be separated by only one space. | |
*/ | |
function LetterCapitalize (str) { | |
let wordArray = str.split(" "); | |
capitalize = function (word) { | |
return word.charAt(0).toUpperCase() + word.slice(1); |
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
// Eloquent Javascript, Chapter 4, Coding Challenge #1 | |
/* Write a range function that takes two arguments, start and end, and returns an array containing all the numbers from start up to (and including) end. */ | |
function range (start, end, step) { | |
let rangeArray = []; | |
for (let i = start; i <= end; i += step) { | |
rangeArray.push(i); | |
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
// Eloquent Javascript, Chapter 4, Coding Challenge #2 | |
/*Arrays have a reverse method which changes the array by inverting the order in which its elements appear. For this exercise, write two functions, reverseArray and reverseArrayInPlace. The first, reverseArray, takes an array as argument and produces a new array that has the same elements in the inverse order. The second, reverseArrayInPlace, does what the reverse method does: it modifies the array given as argument by reversing its elements. Neither may use the standard reverse method.*/ | |
function reverseArray (array) { | |
let newArray = []; | |
for (let i = array.length; i >= 0; i--) { | |
newArray.push(i); | |
} |
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
/* | |
let list = { | |
value: 1, | |
rest: { | |
value: 2, | |
rest: { | |
value: 3, | |
rest: null | |
} | |
} |
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
function stringifier (input) { | |
if (typeof input === 'string') { //test for string, empty string | |
return '"' + input + '"'; | |
} | |
if (typeof input === 'function' || typeof input === 'undefined') { // test for function or undefined | |
return undefined; | |
} |
OlderNewer