Issue
Could someone tell me how to get alternate values from a range of values, through Angular js?
monthDataCreation(){
var startDay =1;
var endDay = 10;
for (var a = startDay; a < endDay; a++) {
var element = a;
console.log("list values like 1,2,5,7,9... ")
}
}
what I need is if I set a start value and end value and on loop it I should get alternate values.
If it start with even num 2 ends at 10 then the string of alternate value should be 2,4,6,8,10.
If it start with odd num 1 ends at 10 then the string of alternate value should be 1,3,5,7,9
Is there any angular way of solution
Solution
I think you could simply change a++ to a+=2 to achieve the desired output. You then have to change a < endDay to a <= endDay though.
Answered By - Rob
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.