Created
April 18, 2018 09:10
-
-
Save gladchinda/a0748072b2b1f28ac7dbdc048274ba0a to your computer and use it in GitHub Desktop.
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
| let width = 300; | |
| let height = 400; | |
| const landscape = true; | |
| console.log(`${width} x ${height}`); // 300 x 400 | |
| if (landscape) { | |
| // An extra variable needed to copy initial width | |
| let initialWidth = width; | |
| // Swap the variables | |
| width = height; | |
| // height is assigned the copied width value | |
| height = initialWidth; | |
| console.log(`${width} x ${height}`); // 400 x 300 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment