---
# System prepended metadata

title: Jaynika Tandel

---

# Jaynika Tandel

# Question 1: Find the 2nd largest number in an array.
```javascript=
var arr = [1,2,3,4,5]
var m1 = -Infinity;
var m2 = -Infinity;
for(var i=0;i<arr.length;i++){
    if(m1<arr[i]){
        m1=arr[i]
    }
    if(m2<arr[i] && m2<m1){
        m2 = arr[i]
    }
    
}


```

# Question 2: Count the superstar elements in an array.


var arr=[1, 2, 13, 4, 10, 8, 9]


13 - superstar
```javascript=
var arr=[1, 2, 13, 4, 10, 8, 9]
var max = -Infinity
var count =0
for(var i=arr.length-2;i>=0;i--){
    if(max<arr[i]){
        max = arr[i]
    }
    if(max<arr[i-1]){
        count++

    }
}
console.log(count+1)



```


# Question 3: 
```javascript=
const array = [1,2 ,3, 4, 5];
var sum = 0;
for(var i=0;i<array.length;i++){
    sum = sum +array[i]
}
console.log(sum)


array.reduce((curr,acc)=>{
    return curr +acc
})
//


```