This file contains hidden or 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
/** | |
* Sorter function for sorting an array of strings by their length, in descending order | |
* @param {string} a | |
* @param {string} b | |
* @returns positive/negative number representing relative comparison of the two elements | |
*/ | |
function byLength(a, b) { | |
return b.length - a.length; | |
} |
This file contains hidden or 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
/** | |
* @typedef {(0 | 1)[][]} IslandInput | |
*/ | |
/** | |
* @typedef {Object} Island | |
* @property {string[]} coordinates | |
*/ | |
/** |
This file contains hidden or 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
html { | |
--blue: #61DBFB; | |
--blue-dark: #1d8099; | |
font-family: Raleway; | |
margin: 0; | |
} | |
body { | |
margin: 0; | |
height: 100vh !important; |
This file contains hidden or 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
/** | |
* Comparison function for sorting an array of strings by length | |
* @param {string} a first word from dictionary | |
* @param {string} b second word from dictionary | |
* @return {number} relative order of the two strings | |
*/ | |
function byLength(a, b) { | |
return b.length - a.length; | |
} |
This file contains hidden or 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
/** | |
* Gets the previous number in the Fibonacci sequence, or -1 if this number isn't in the sequence | |
* @param {number} num | |
* @returns {number} previous Fibonacci number (or -1) | |
*/ | |
function getPreviousFibonacciNumber(num) { | |
// Handle negatives | |
if (num <= 0) { | |
return -1; | |
} |
This file contains hidden or 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
/** | |
* Determines whether all characters in a string are unique. | |
* | |
* Original question: | |
* **Write a function that determines if all the characters in a given string are unique.** | |
* Can you do this without making any new variables? You choose if you want to include | |
* capitalization in your consideration for this one, as a fun challenge. | |
* | |
* @param {string} str string to test | |
* @param {boolean} [caseSensitive] whether to take capitalization into account |
This file contains hidden or 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
const ORIGIN = 1; | |
const DESTINATION = 2; | |
const WALL = 3; | |
/** | |
* @typedef {{ | |
* coordinates: string, | |
* distanceFromOrigin: number, | |
* shortestPaths: Direction[][] | |
* }} DjikstraNode |
This file contains hidden or 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
/** | |
* Comparison function for two integers which will sort the bigger one first | |
* @param {number} int1 | |
* @param {number} int2 | |
*/ | |
function bySize(int1, int2) { | |
return int2 - int1; | |
} | |
/** |
This file contains hidden or 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
/** | |
* Evaluate a string's results after backspaces and forward deletions. | |
* A `#` is a backspace, removing the previous undeleted character. | |
* A `%` is a forward deletion, removing the next letter. | |
* @param {string} str | |
* @returns {string} provided string, with deleted characters removed | |
*/ | |
function evaluateString(str) { | |
const characters = str.split(''); |
This file contains hidden or 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
const CORRECT = 'correct'; | |
const OUT_OF_PLACE = 'out of place'; | |
const WRONG = 'wrong'; | |
/** | |
* Determines which letters in a given guess are correct, which ones are out of place, and which ones are invalid and returns emoji string | |
* @param {string} guess five-letter guess (presumes the guess has already been through other formatting validations like length and valid characters) | |
* @param {string} solution the target word the player is trying to guess | |
* @returns {string} emoji sequence | |
*/ |
NewerOlder