# Vishal Kumar - Nodejs(~2), Typescript - DynamoDB - AWS - SQS, Lambda, Kinesis, S3 - Firebase, sendGrid, gupshup, newrelic, moengage, Google APIs # Question 1: ```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: 'G'}, ] const result = { 5: { 10: ['B', 'D', 'F'], }, 6: { 9: ['A'] 11: ['C'], 12: ['E'], }, 7: { 12: ['G'] } } function getResult(arrObj) { let result = {}; arrObj.forEach(obj => { if (result[obj[clas]]) { reduceAgeAndName(result[obj[clas]], obj); } else { result[result[obj[clas]]] = {}; reduceAgeAndName(result[result[obj[clas]]], obj); } }); } function reduceAgeAndName(existing, newObj) { if (existing[newObj[age]].length) { existing[newObj[age]].push(newObj[name]); } else { existing[newObj[age]] [newObj[name]] } } ``` # Question 2: - Array [1, 2, 3, 4, 5] - length = 0 < length < Array.length for(i = 0; i<arr.lenth-length) let arr = new Array(); length = 3 i = 0, i++, i<arr.length-3 [1,2,3] [2,3,4] [3,4,5] i= 1 i = i+2; [1, 2, 3] = [1, 2, 4] [1, 2, 5] [1, 3, 4] [1, 3, 5] [1, 4, 5] [2, ...] [1, 2, 3, 4, 5] i= 0 getArray(arr,i, subArray); getArrayWithMissedValue(arr,i+1, subArray) i=0 [1] [] | i+1=1 [2] [] i= 1 [1,2] . . .