Created
May 5, 2021 05:19
-
-
Save mannuelf/9da82960746e62d4fa155d006225c2b1 to your computer and use it in GitHub Desktop.
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 rectangular = (state) => { | |
return { | |
area: () => { | |
return state.height * state.width; | |
} | |
}; | |
}; | |
const openable = (state) => { | |
return { | |
toggleOpen: () => { | |
state.open = !state.open | |
} | |
} | |
}; | |
const buildRectangleWindow = (state) => { | |
return Object.assign(state, rectangular(state), openable(state)); | |
}; | |
const rectangleWindow = buildRectangleWindow({ | |
height: 20, | |
widht: 20, | |
open: false | |
}); | |
rectangleWindow.open; | |
rectangleWindow.toggleOpen(); | |
rectangleWindow.open; | |
// https://www.udemy.com/course/typescript-the-complete-developers-guide/learn/lecture/15066838#notes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment