Skip to content

Instantly share code, notes, and snippets.

@McLarenCollege
Last active October 24, 2022 13:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save McLarenCollege/9be6c2ab7c909d2c012d9c4d0be10a6d to your computer and use it in GitHub Desktop.
Save McLarenCollege/9be6c2ab7c909d2c012d9c4d0be10a6d to your computer and use it in GitHub Desktop.
Swap Two Numbers

Write code to swap the two given numbers.

Hint: You will need to create a new variable

CODE TEMPLATE


let num1 = 20;
let num2 = 30;
// Write your code here
console.log(num1, num2); // should give 30 20

@AmandaShashaa
Copy link

let num1 = 20;
let num2 = 30;
let temp = 20
num1 = num2
num2 = temp
console.log(num1, num2);

@Chimoneg27
Copy link

May you please not post your solution on the comments. We have been kindly told not to do so. Thank you, Amanda

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment