# How to swap two integer

Last week, I was on a job interview and given a challenge, how to swap an integer value between two variables. So given this code:

```
var a = 10
var b = 2
```

I should think how to swap `a`

and `b`

values. The first solution that comes up in my mind, some like this:

```
a = [a, b]
a = a[0]
b = a[1]
```

Turn out that I can’t change the datatype, LOL. So, after solid 3 minutes, I propose another solution:

```
a = 2
b = 10
```

LMFAO. Basically it works fine and correct but can’t be used if `a`

and/or `b`

have different value. After 10 minutes without a solution, I gave up and they show me the correct answer. It’s so fucking simple.

```
a = a + b // 12
b = a - b // 10
a = a - b // 2
```