Test case details

Preparation Code

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.6/angular.min.js"></script>
var dataset, i, retObj = {}, stats = [{         "window": "lifetime",         "source": "DX",         "spend": "1642.81",         "ideal_spend": "2989.86",         "pace": "43",         "impressions": "224929",         "actions": "189",         "cpm": "3.90",         "ideal_cpm": "2.81",         "cpa": "25.82"       }, {         "window": "yesterday",         "source": "DX",         "spend": "1634.57",         "ideal_spend": "3276.75",         "pace": "24",         "impressions": "24771",         "actions": "41",         "cpm": "2.08",         "ideal_cpm": "3.14",         "cpa": "16.00"       }];

Test cases

Test #1

angular.forEach(stats, function(dataset) {   if (dataset.window && dataset.window === 'lifetime') {     delete dataset.window;     retObj = dataset;   } });

Test #2

for (i = 0; i < stats.length; i++) {   dataset = stats[i];   if (dataset.window && dataset.window === 'lifetime') {     delete dataset.window;     retObj = dataset;     break;   } }