Swapping Values Using Arithmetic Operations in JavaScript
Jun 8, 2022 · 2 min read · Assume we have two variables a and b: let a = 5; let b = 7; Let us swap the values. First we get the sum of the two variables and assign it to a a = a + b; // a = 12 Now, let us reasign the value of b with the value of a by getting the difference b =...
Join discussion