tash2020 Posted May 15, 2020 Share Posted May 15, 2020 Hello, I'm on a journey to compare if the current date equals various dates. If this is valid then play the timeline. Can someone look at my code and point me in the right direction? See the Pen yLYEpZJ by nbryson (@nbryson) on CodePen Link to comment Share on other sites More sharing options...
Shaun Gorneau Posted May 15, 2020 Share Posted May 15, 2020 Hi @tash2020, There are quite a few syntax errors in your code, to start. Semicolons, while not required, should be used ... it helps to understand the code better. And then there are a few logic and structure issues. First thing I'll point out is your goal is to compare certain dates to the current date ... but there is not current date established anywhere. Putting that aside and using some created dates, we can move onto the other issues. If you want the timeline to play only if conditions are met, it's easier to use the pause property when constructing the timeline. const tldot = gsap.timeline( { repeat: -1, paused: 1 } ); This block is not closed properly, and you can't compare three items in this way. You'd have to create a function that takes 3 (or more) values and does the comparison and returns true/false. const isBlinking = (date1, date2, date3) => { if(date1.getFullYear() === date2.getFullYear() === date3.getFullYear() && date1.getMonth() === date2.getMonth() === date3.getMonth() && date1.getDate() === date2.getDate() === date3.getdate()) tldot.play(); } else { tldot.pause(); } Here is a codeine addressing these issues. See the Pen jObvXbK?editors=1111 by sgorneau (@sgorneau) on CodePen 3 1 Link to comment Share on other sites More sharing options...
ZachSaucier Posted May 15, 2020 Share Posted May 15, 2020 1 hour ago, Shaun Gorneau said: paused: 1 I've never seen people use 1 there before 3 Link to comment Share on other sites More sharing options...
Shaun Gorneau Posted May 15, 2020 Share Posted May 15, 2020 1 minute ago, ZachSaucier said: I've never seen people use 1 there before That was pre-coffee this morning, lol. 🥴 I'm a 0/1 kind of guy, but even here I usually use true 😆 3 Link to comment Share on other sites More sharing options...
PointC Posted May 15, 2020 Share Posted May 15, 2020 2 hours ago, Shaun Gorneau said: That was pre-coffee this morning, lol. 🥴 I'm a 0/1 kind of guy, but even here I usually use true 😆 01001100 01001111 01001100 4 Link to comment Share on other sites More sharing options...
ZachSaucier Posted May 15, 2020 Share Posted May 15, 2020 3 minutes ago, PointC said: 01001100 01001111 01001100 I remember learning how to do those conversions at uni. Never going to use that skill again, LOL 1 Link to comment Share on other sites More sharing options...
Shaun Gorneau Posted May 15, 2020 Share Posted May 15, 2020 5 minutes ago, PointC said: 01001100 01001111 01001100 Beep boop 😆 1 1 Link to comment Share on other sites More sharing options...
Rodrigo Posted May 15, 2020 Share Posted May 15, 2020 2 hours ago, Shaun Gorneau said: I'm a 0/1 kind of guy, but even here I usually use true 😆 There are 10 types of persons, the ones that understand binary and the ones who don't 2 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now