Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to skip every 3rd number from loop

I want to skip every third number from logic, I tired but I'm not getting the correct way. output should be like this: 0,1,3,4,6,7,9,10,12...

I tried this, but its not working fully. **

for (var item = 0; item < $scope.gridImportData.data.length; item++)
{
  $scope.gridImportData[item] + (($scope.gridImportData[item] - 1) / 3)
}

**

like image 659
Akanksha_R Avatar asked Mar 16 '26 09:03

Akanksha_R


1 Answers

Try this

    angular.module("a",[]).controller("ac",function($scope){
    $scope.querylist =[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15];
    $scope.newValue=[];
    for (var item = 0; item < $scope.querylist.length; item++){
    if($scope.querylist[item] % 3 == 0 && $scope.querylist[item] !=0)    {
        continue;
       }
      $scope.newValue.push($scope.querylist[item]);
    }

    });
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="a" ng-controller="ac">
    <table>
    <tr ng-repeat="x in newValue">
       <td>{{x}}</td>
    </tr> 
    </table>
    </div>
like image 142
Ramesh Rajendran Avatar answered Mar 17 '26 23:03

Ramesh Rajendran