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
/** | |
* Time complexity: O(6) | |
* Space complexity: O(3n) - almost 3x original array size? No entirely sure | |
* | |
* Assumes that the inputs are valid | |
* | |
* @param openingParenthesisIndex Zero based index of '(' in str | |
* @param str String to search - must be equal # of '(' and ')' | |
*/ | |
const getCorrespondingClosingParenthesesIndex = (openingParenthesisIndex: number, str: string): number => { |
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
// Type JavaScript here and click "Run Code" or press Ctrl + s | |
console.log('Hello, world!'); | |
// CHALLENGE 1 | |
function createFunction() { | |
return function () { | |
console.log('hello'); | |
} | |
} |
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
// Type JavaScript here and click "Run Code" or press Ctrl + s | |
// Challenge 1 | |
function addTwo(num) { | |
return num + 2; | |
} | |
// To check if you've completed it, uncomment these console.logs! | |
console.log(addTwo(3)); |