Destructuring assignment | JavaScript

CodeCatch

May 6th, 2021 09:06:12 AM

					
//JavaScript program to swap two variables //take input from the users let a = prompt('Enter the first variable: '); let b = prompt('Enter the second variable: '); //using destructuring assignment [a, b] = [b, a]; console.log(`The value of a after swapping: ${a}`); console.log(`The value of b after swapping: ${b}`);

Featured Posts