From 3425ebe75a48956adf69ffc55384a4b79aa6cc25 Mon Sep 17 00:00:00 2001 From: Kayce Hubbard Date: Tue, 8 Aug 2017 11:34:28 -0500 Subject: [PATCH 1/3] Update with longestString complete. --- longestString/longestString.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/longestString/longestString.js b/longestString/longestString.js index 35b887c..33040a5 100644 --- a/longestString/longestString.js +++ b/longestString/longestString.js @@ -2,3 +2,13 @@ * Write a function that accepts an array of strings. * Return the longest string in the array. */ + +const longestString = (stringArray) => { + let currentLongest = stringArray[0]; + for(strings of stringArray) { + if(strings.length > currentLongest.length) { + currentLongest = strings; + } + } + return currentLongest; +} \ No newline at end of file From 854a3c9f8bd3d814a7459e94357a80031f0da09f Mon Sep 17 00:00:00 2001 From: Kayce Hubbard Date: Wed, 9 Aug 2017 11:24:15 -0500 Subject: [PATCH 2/3] Updates reverseCase with working solution. --- reverseCase/reverseCase.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/reverseCase/reverseCase.js b/reverseCase/reverseCase.js index f1051f5..74a7f0a 100644 --- a/reverseCase/reverseCase.js +++ b/reverseCase/reverseCase.js @@ -2,4 +2,19 @@ * Write a function that reverses the case of each letter in the strings that it receives. * Example: 'Hello World' -> 'hELLO wORLD' * Assume that each string will contain only spaces and letters. - */ \ No newline at end of file + */ + + const reverseCase = (str) => { + let newString = ''; + for (let i = 0; i < str.length; i++) { + let character = str.charCodeAt(i); + if ((character >= 65) && (character <= 90)) { + newString = newString + (str.charAt(i).toLowerCase()); + } else if ((str.charCodeAt(i) >= 97) && (str.charCodeAt(i) <= 122)) { + newString = newString + (str.charAt(i).toUpperCase()); + } else { + newString = newString + ' '; + } + } + return newString; +} From cfc6e1f78dcfb48a20c4dd945f068a722f138e4a Mon Sep 17 00:00:00 2001 From: Kayce Hubbard Date: Thu, 10 Aug 2017 11:43:35 -0500 Subject: [PATCH 3/3] Updates isUnique.js with working solution. --- isUnique/isUnique.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/isUnique/isUnique.js b/isUnique/isUnique.js index 6c9caf5..7489ab2 100644 --- a/isUnique/isUnique.js +++ b/isUnique/isUnique.js @@ -1,3 +1,14 @@ /* Implement an algorithm to determine if a string has all unique characters. * What if you cannot use additional data structures? - */ \ No newline at end of file + */ + + const isUnique = (str) => { + let currentChar = str.charAt(0); + for(let i = 1; i < str.length; i++) { + let newChar = str.charAt(i); + if(currentChar === newChar) { + return false; + } + } + return true; +};