# Backend Interview questions
## Exercise 1
Given an integer called `sum` and an array of integers called `numbers`, check whether there’s a combination of any two elements in the `numbers` array that can be added to equal `sum` exactly.
### Example:
* **Input:** `sum = 17`, `numbers = [1, 9, 2, 8]`, **Answer:** `true` since `9 + 8 = 17`
* **Input:** `sum = 4`, `numbers = [1, 9, 2, 8]`, **Answer:** `false`
<!-- ### Answer:
```javascript
function checkSumInArray(sum, numbers) {
const parsedNumbers = {};
for (let i = 0; i < numbers.length; i++) {
const diff = sum - numbers[i];
if (parsedNumbers[diff]) {
return true;
} else {
parsedNumbers[numbers[i]] = true;
}
};
return false;
}
``` -->
## Exercise 2
Your company assigns each customer a membership ID, and you are implementing a check digit for those IDs. The check digit should be calculated by adding up all digits in each membership ID. If the result of the sum is a number with more than a single digit, another iteration is required, and the digits of the result also should be added together. This process should repeat until a single-digit number is calculated.
### Example:
For the membership ID `"55555"` the sum of all digits is `25`. Because this is not a single-digit number, `2` and `5` would be added, and the result, `"7"`, would be the check digit.
<!-- ### Answer:
```javascript
function checkDigit(num) {
let tot = 0;
let splity = num.split('');
for(let i = 0; i < splity.length; i++) {
tot += parseInt(splity[i]);
}
if (tot > 9) {
return checkDigit(tot.toString());
} else {
return num;
}
}
```
-->
## Exercise 3
You are climbing stairs. It takes `n` steps to get to the top. Each time, you can take 1 step or 2 steps. How many distinct ways to get to the top?
### Example:
  
* **Input:** `n = 1`, **Answer:** `1` | **Input:** `n = 2`, **Answer:** `2` | **Input:** `n = 3`, **Answer:** `3`
<!-- ### Answer:
```javascript
function climbStairs(n) {
if (n == 1) return 1;
if (n == 2) return 2;
return climbStairs(n - 1) + climbStairs(n - 2);
}
``` -->