Skip to content
Open
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
15 changes: 9 additions & 6 deletions Day01/Problem01.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ class Problem {
* separated by single spaces.
*/
wordCount(input) {
// code goes here
return null;
return input.split(" ").length;
}


Expand All @@ -17,7 +16,8 @@ class Problem {
*
*/
letterCapitalize(str) {
return null;

return str.split(" ").map( i =>{return (i.charAt(0).toUpperCase() + i.slice(1))}).join(" ");
}


Expand All @@ -29,7 +29,7 @@ class Problem {
*/

firstReverse(input){
return null;
return input.split(" ").map(i => {return i.split("").reverse().join("")}).reverse().join(" ");
}

/**
Expand All @@ -40,7 +40,10 @@ class Problem {
*/
longestWord(input) {
// code goes here
return null;
var arr = input.replace(/[^a-zA-Z ]/g,"").split(" ");

arr.sort(function(a,b) { return b.length - a.length } );
return arr.shift();
}

/**
Expand All @@ -50,7 +53,7 @@ class Problem {
*/
swapCase(str) {
// code goes here
return null;
return str.split("").map(l=>l==l.toLowerCase()?l.toUpperCase():l.toLowerCase()).join("");
}

}
Expand Down