` ``

var thirdMax = function(nums) {

```
//2. iterate; keep track of largest, second largest, third largest
var largest = nums[0];
var third;
var second;
for(var i = 1; i < nums.length; i++){
if(nums[i] === largest || nums[i] === second || nums[i] === third) continue;
if(nums[i] > largest){
var temp1 = largest;
var temp2 = second;
largest = nums[i];
second = temp1;
third = temp2;
}else if(nums[i] > second || !second){
third = second;
second = nums[i];
} else if(nums[i] > third || !third){
third = nums[i];
}
}
if(!third) return largest;
return third;
```

};

` ``