---
# System prepended metadata

title: Venkatesh

---

# Venkatesh

- MERN

# Question 1: Js question
```javascript!
const arrObj = [
    { age: 9, class: 6, name: 'A'},
    { age: 10, class: 5, name: 'B'},
    { age: 11, class: 6, name: 'C'},
    { age: 10, class: 5, name: 'D'},
    { age: 12, class: 6, name: 'E'},
    { age: 10, class: 5, name: 'F'},
    { age: 12, class: 7, name: 'F'},
]

/**
{
    5: {
        10: ['B', 'D', 'F']
    },
    6: {
        9: ['A'],
        11: ['C'],
        12: ['E']
    },
    7: {
        12: ['F']
    }
}
*/


function convert(arr) {
    let obj = {};
    for (let i = 0; i < arr.length; i++) {
        if (obj[arr[i].class] === undefined) {
            obj[arr[i].class] = {};
            obj[arr[i].class][arr[i].age] = [arr[i].name];
        }
        else {
            if (obj[arr[i].class][arr[i].age] === undefined) {
                obj[arr[i].class][arr[i].age] = [arr[i].name];
            }
            else {
                obj[arr[i].class][arr[i].age].push(arr[i].name);
            }
        }
    }
    return obj;
}

console.log(convert(arrObj));



```


# Question 2: 
```javascript!
const obj = {
    a: 'Hello',
    b: { c: 10 },
    d: {e: {f: 'World', g: "hello"}}
}


result = {
    a: 'Hello',
    b_c: 10,
    d_e_f: 'World',
    d_e_g: 'hello'
}



const obj = {
    a: 'Hello',
    b: { c: 10, j: 20 },
    d: { e: { f: 'World', g: "hello", i: "i" } }
}


let newObj = {};

function objectConvert(obj, ch) {
    for (let key in obj) {
        if (ch == "") {
            ch = key;
        }
        else {
            ch += "_" + key;
        }
        if (typeof obj[key] == 'object') {
            ch = objectConvert(obj[key], ch);
        }
        else {
            newObj[ch] = obj[key];
            ch = ch.slice(0, ch.length - 2);
        }
    }
    return "";
}
objectConvert(obj, "");

console.log(newObj);






```



# Question 3: 
```javascript!
let arr = [1, 2, 1, 2, 3, 1, 2, 4, 2, 4, 1, 4];

let minCount = Infinity;
let min = "";

let obj = {};

for (let i = 0; i < arr.length; i++) {
    if (obj[arr[i]] === undefined) {
        obj[arr[i]] = 1;
    }
    else {
        obj[arr[i]]++;
    }
}

for (let key in obj) {
    if (obj[key] < minCount) {
        minCount = obj[key];
        min = key;
    }
}

console.log(min);



```