?
Solved

AngularJS Chaining IF Statement

Posted on 2014-10-24
1
Medium Priority
?
113 Views
Last Modified: 2014-11-18
I'm attempting to chain a group of variables to create a single IF statement. If I run each statement individually, I will get the expected results. Is there a better way to accomplish this?

                var upcomingDate = moment(object["upcomingdate"]);
                var monthlyDateFuture = moment().diff(upcomingDate, 'days') > 30 && object["Frequency"] == 'monthly';
                var biWeeklyFuture = moment().diff(upcomingDate, 'days') > 14 && object["Frequency"] == 'biweekly';
                var weeklyFuture = moment().diff(upcomingDate, 'days') > 7 && object["Frequency"] == 'weekly';
                var biMonthlyFuture = moment().diff(upcomingDate, 'days') > 60 && object["Frequency"] == 'bimonthly';
                var quarterlyFuture = moment().diff(upcomingDate, 'days') > 90 && object["Frequency"] == 'quarterly';

                if (monthlyDateFuture && biWeeklyFuture && weeklyFuture && biMonthlyFuture && quarterlyFuture) {
                       $scope.summary[segment].totalLateRelationships++;
                       $scope.summary[segment].lateRelationships.push(object);    
                }

Open in new window

0
Comment
Question by:brendanlefavre
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 82

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 40403931
look like you need OR operators not AND :
if (monthlyDateFuture || biWeeklyFuture || weeklyFuture || biMonthlyFuture || quarterlyFuture) {

Open in new window

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
This article was originally published on Monitis Blog, you can check it here . Today it’s fairly well known that high-performing websites and applications bring in more visitors, higher SEO, and ultimately more sales. By the same token, downtime…
This video teaches users how to migrate an existing Wordpress website to a new domain.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question