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
const profiles = [ | |
{ | |
lastName: "Curry", | |
firstName: "Steph", | |
team: "WARRIORS" | |
}, | |
{ | |
lastName: "James", | |
firstName: "Lebron", | |
team: "LAKERS", |
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
enum PrimaryColor { | |
Red = "RED", | |
Yellow = "YELLOW", | |
Blue = "BLUE" | |
} | |
const green = [ | |
{ color: PrimaryColor.Yellow, weight: 1 / 2 }, | |
{ color: PrimaryColor.Blue, weight: 1 / 2 } | |
] as const; |
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
const HOURS_IN_DAY = 24; | |
/** | |
* NOT VALID; imagined API for mutating numbers | |
*/ | |
24.increment(); | |
HOURS_IN_DAY === 25; // true |
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
const oneHundred = 100; // <-- now a `const` instead of a `let` | |
const decrementOneHundred = x => oneHundred - x; | |
decrementOneHundred(20); // 80 | |
// oneHundred = 80; <-- would be runtime error: "TypeError: Assignment to constant variable." | |
decrementOneHundred(20); // 80 |
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
const square = x => x * x; | |
const sum = (x, y) => x + y; | |
const sumOfSquares = (x, y, z) => sum(sum(square(x), square(y)), square(z)); | |
sumOfSquares(1, 2, 3); // 14 |
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
const square = x => x * x; | |
const sum = (x, y) => x + y; | |
// PSUEDO CODE | |
sum(sum(square(USER_INPUT_1), square(USER_INPUT_2)), square(USER_INPUT_3)); | |
// REPL PSUEDO CODE | |
// > run functionalProgram.js with USER_INPUT_1=1, USER_INPUT_2=2, USER_INPUT_3=3, | |
// > 14 |
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
class BankAccount { | |
public balance; // <-- now public | |
constructor(funds) { | |
this.balance = funds; | |
} | |
public withdraw(amount) { | |
this.balance = this.balance - amount; | |
} |
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
class BankAccount { | |
public withdraw(balance, amount) { | |
return balance - amount; | |
} | |
public checkBalance(balance) { | |
return balance; | |
} | |
} |
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
function loginOrReloadAndGetPage(page: BasePage, username, password) { | |
page.load(); | |
... | |
page.waitForInitLoaded(); | |
... | |
if (!page.isLoggedIn()) { | |
... | |
page.waitForInitLoaded(); | |
} | |
return page.waitForLoaded(); |
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
class BuyingFlow extends BasePage { | |
... | |
} | |
class BuyingFlow implements BasePageI { | |
load() {} | |
waitForInitloaded() {} | |
} | |
const BuyingFlow: BasePageI = { |