JavaScript program to swap two variables Using Arithmetic Operators

Publicado em: 03 Novembro 2022
no canal de: Tech Tips
136
2

Example 3: Using Arithmetic Operators
//JavaScript program to swap two variables

//take input from the users
let a = parseInt(prompt('Enter the first variable: '));
let b = parseInt(prompt('Enter the second variable: '));

// addition and subtraction operator
a = a + b;
b = a - b;
a = a - b;

console.log(`The value of a after swapping: ${a}`);
console.log(`The value of b after swapping: ${b}`);
Run Code
Output

Enter the first variable: 4
Enter the second variable: 2
The value of a after swapping: 2
The value of b after swapping: 4


Nesta página do site você pode assistir ao vídeo on-line JavaScript program to swap two variables Using Arithmetic Operators duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário Tech Tips 03 Novembro 2022, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 136 vezes e gostou 2 espectadores. Boa visualização!