**Parspec Interview Process**
**Round 1 – HR/AI Screening:**
The HR or an AI bot asked basic JavaScript questions:
* What’s the difference between `==` and `===`?
* What is a higher-order function?
* What is a currying function?
* What is a pure function?
* Difference between pure and impure functions
* Difference between `let` and `var`
**Some code questions they asked:**
1. **Hoisting and Scoping Example:**
```javascript
function userDetails(username) {
if (username) {
console.log(salary); // undefined
console.log(age); // error
let age = 30;
var salary = 10000;
}
console.log(salary); // 10000
console.log(age); // error
}
userDetails("John");
```
**Output:**
```
undefined
ReferenceError: Cannot access 'age' before initialization
10000
ReferenceError: age is not defined
```
2. **Async Execution (setTimeout and Promises):**
```javascript
console.log(1);
setTimeout(() => console.log('setTimeOut'), 0);
Promise.resolve().then(() => console.log('P1')).then(() => console.log('P2')).then(() => console.log('P3'));
console.log(2);
```
**Output:**
```
1
2
P1
P2
P3
setTimeOut
```
3. **Variable Hoisting:**
```javascript
console.log(x);
var x = 2;
```
**Output:**
```
undefined
```
4. **Global Variable Trap:**
```javascript
(function(){
var a = b = 1;
})();
console.log('b', b); // b is global
console.log('a', a); // a is not defined
```
**Output:**
```
b 1
ReferenceError: a is not defined
```
5. **Function Expression Hoisting:**
```javascript
console.log(test3);
console.log(test3());
var test3 = function() { return 3; };
```
**Output:**
```
undefined
TypeError: test3 is not a function
```
---
Round 2 – HackerEarth Test:
1. React multiple choice questions
2. Small project: Book Management System using Context API
---
Round 3 – Technical Interview:
1. Sort a binary array (0s and 1s) in-place in O(n) time and O(1) space
2. Find unique pairs of 2-digit numbers where the sum of digits equals a given target
Example: `[2,1,3,9,4,6,10,-1]`, target = 5
3. Loop with setTimeout:
```javascript
for(var i=0; i<5; i++) {
setTimeout(() => console.log(i));
}
```
* Make it print `5` five times
* Make it print `0` to `4` using `var`, not `let`
4. **Concepts:**
* `call`, `apply`, `bind`
* `map` vs `forEach`
---
Round 4 – System Design
* Asked to design architecture for a Google-scale product.
* Personally found this round unnecessary in today’s world, where AI handles much of the things