Skip to content

Instantly share code, notes, and snippets.

@gladchinda
Created April 18, 2018 09:10
Show Gist options
  • Select an option

  • Save gladchinda/a0748072b2b1f28ac7dbdc048274ba0a to your computer and use it in GitHub Desktop.

Select an option

Save gladchinda/a0748072b2b1f28ac7dbdc048274ba0a to your computer and use it in GitHub Desktop.
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