Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAnton Kilk
Full Stack JavaScript Techdegree Student 11,256 PointsI run this code and keep getting 1.5 as dailyFine. Not 1.4 as shown in explanation and as should be for 14 days.
Indeed, if you check the 'daysLate' value, it gives '15'. Why? Snapshot:https://w.trhou.se/n0iw7i49xy
6 Answers
rydavim
18,814 PointsThe snapshot you posted above works as expected for me. dailyFine
is 0.1, daysLate
is 14, and balance
is 1.4. I would try a hard refresh, but I can't think of a reason why it might be coming back differently for you with the same code. If you're still having issues, what browser are you using?
Steven Parker
231,248 PointsI'm not seeing the issue, the "daysLate" amount logged on the console is 14.
But where's the code that you use to show the amount?
Anton Kilk
Full Stack JavaScript Techdegree Student 11,256 PointsStrange. I still get 15 days and 1.5 as balance. I updated the code with 'console.log(patron.balance);' to see the balance as well. Here is the snapshot once again: https://w.trhou.se/5xt1d87pl0. Please let me know, if you know what can be the issue. I use Google Chrome Version 77.0.3865.90 (Official Build) (64-bit)
rydavim
18,814 PointsI'm still getting the expected behavior.
With the way JS implements Date
, this shouldn't matter - but what timezone are you in? If you log out now
and dateDiff
, what do you get?
Anton Kilk
Full Stack JavaScript Techdegree Student 11,256 PointsHi rydavim ! I am in Helsinki timezone: Eastern European Summer Time Time zone in Helsinki (GMT+3) Friday, 18 October 2019, 10.29
I get these answers: dateDiff: Thu Jan 15 1970 02:00:00 GMT+0200 (Eastern European Standard Time) now: Fri Oct 18 2019 10:36:06 GMT+0300 (Eastern European Summer Time) Something wrong with dateDiff variable, isn't it? I wonder, why does it work in your region...
Maciej Glowacki
Front End Web Development Techdegree Graduate 17,996 PointsI have same issue and I don't see any solution so far. To get the same value of fine I have to manipulate the days from when It counts the fine.
aure
Front End Web Development Techdegree Graduate 16,472 PointsI have the same problem... If somebody knows the solution... ?
Steven Parker
231,248 PointsStart a fresh question and show your own code in it.
i1276
7,626 PointsI get the same result (1.5) even when running the code provided by Ashley (from workspace) Using Google Chrome v 92 and my timezone is +7 GMT
Steven Parker
231,248 PointsSteven Parker
231,248 PointsPlease post your code (with Markdown formatting) or make a snapshot of your workspace and post the link to it here.