From dd2083e861560aa6cb22d42bb45da90d078fab02 Mon Sep 17 00:00:00 2001 From: kcee917 Date: Wed, 3 Mar 2021 10:12:52 -0500 Subject: [PATCH 1/2] First commit --- Day01/Problem01.js | 104 ++++++++++++++++++++++++++------------------- 1 file changed, 60 insertions(+), 44 deletions(-) diff --git a/Day01/Problem01.js b/Day01/Problem01.js index 6ad3c39..21fb02d 100644 --- a/Day01/Problem01.js +++ b/Day01/Problem01.js @@ -1,57 +1,73 @@ class Problem { - /** - * Have the wordCount(input) take the str string parameter being passed - * and return the number of words the string contains - * (e.g. "Never eat shredded wheat or cake" would return 6). Words will be - * separated by single spaces. - */ - wordCount(input) { - // code goes here - return null; - } + /** + * Have the wordCount(input) take the str string parameter being passed + * and return the number of words the string contains + * (e.g. "Never eat shredded wheat or cake" would return 6). Words will be + * separated by single spaces. + */ +// Declare the variable +wordCount(input) { + //Declare variable + // Split string into an array of substrings + str = str.split(" "); + // Count the number of substrings(words) + return str.split(" ").length +} - /** - * 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. - * - */ - letterCapitalize(str) { - return null; +/** + * 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. +* +*/ +letterCapitalize(str) { + // Split string into an array of substrings + str = str.split(" "); + //For loop to capture 1st letter of each substring + for(var i = 0, x = str.length; i < x; i++) { + //Capitalize 1st letter of each substring + str[i] = str[i[0].toUpperCase() + str[i].substr(1); } + //Return all substrings together + return str.join; +} - /** - * Have the function firstReverse(String input) take the input parameter being passed and - * return the string in reversed order. For example: if the input string is "Hello World and Coders" then your - * program should return the string sredoC dna dlroW olleH. - */ +/** + * Have the function firstReverse(String input) take the input parameter being passed and + * return the string in reversed order. For example: if the input string is "Hello World and Coders" then your + * program should return the string sredoC dna dlroW olleH. + */ - firstReverse(input){ - return null; - } +firstReverse(input){ + // Split string into an array of substrings + str = str.split(" "); + // Reverse the order of the substrings and join them together. + return str.split("").reverse().join(""); +} - /** - * Have the longestWord(String input) take the input 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 - * input will not be empty. - */ - longestWord(input) { - // code goes here - return null; - } - /** - * Have the swapCase(String input) take the input parameter and swap the case of each - * character. For example: if str is "Hello World" the output should be hELLO wORLD. - * Let numbers and symbols stay the way they are. - */ - swapCase(str) { - // code goes here - return null; - } +/** + * Have the longestWord(String input) take the input 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 + * input will not be empty. + */ +longestWord(input) { + // code goes here + return null; +} + +/** + * Have the swapCase(String input) take the input parameter and swap the case of each + * character. For example: if str is "Hello World" the output should be hELLO wORLD. + * Let numbers and symbols stay the way they are. + */ +swapCase(str) { + // code goes here + return null; +} } From e2e0532a1bb5c1f764f0883da975c8a57c568c75 Mon Sep 17 00:00:00 2001 From: kcee917 Date: Wed, 17 Mar 2021 11:51:55 -0400 Subject: [PATCH 2/2] commit --- Day01/workspace.code-workspace | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 Day01/workspace.code-workspace diff --git a/Day01/workspace.code-workspace b/Day01/workspace.code-workspace new file mode 100644 index 0000000..bab1b7f --- /dev/null +++ b/Day01/workspace.code-workspace @@ -0,0 +1,8 @@ +{ + "folders": [ + { + "path": ".." + } + ], + "settings": {} +} \ No newline at end of file