---
# System prepended metadata

title: Arvind

---

# Arvind

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

// print all student's name in class 5. 

const data=arrObj.map((ele)=>
                        {
if(ele.class==5){
    return ele.name;
}
});
console.log(data);

let data=[];
for(let ele of arrObj){
if(ele.class==5){
data.push(ele.name);
}
}
console.log(data)




// {
//     5: ['A', 'B', 'C'],
//     6: ['D', 'E'],
//     7: ['F']
// }

function datas(arrObj){
    let obj={};
    for(let item of arrObj){
   //     if(item.class==5){
   //        obj[item.class]=item.name;
  //      }
  //      if(item.class==6){
  //          obj[item.class]=item.name;
  //      }
  //        if(item.class==7){
 //           obj[item.class]=item.name;
 //       }
 //   }
    
    if(item.class in obj){
        obj[item.class]=item.name;
    }else{
        obj[item.class]=item.name;
    }
    
    return obj;
    }
 console.log(datas(arrObje));

```




# Question 2: Sort the array. 
```javascript!
[0s...., 1s...., 2s....]

let arr=[2, 0, 1, 1, 0, 0, 2]
let low=0;
let mid=0;
let high=arr.length-1;
let brr=[];
while(low<high)
{
    if(arr[low]==0){
        arr[mid]=0;
        low++;
        mid++;
    }else if(arr[low]==1){
        low++;
        
    }else{
        arr[mid]=2;
        low++;
        high--;
    }
}


```







