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 trial
Gregg Mojica
11,506 PointsJavascript Date & Time
Hey Guys, So I'm working with JS, and checking if the time of the day is between a certain time, then I'll show a certain background on my site. If not, then I won't show anything. I'm just not sure what's wrong with my code, though!?
Any ideas? Thanks!
<script type="text/javascript"> var objDate = new Date(); var hours = objDate.getHours(); if(hours >= 1 && hours <= 21){ var totalCount = 45; function ChangeIt() { var num = Math.ceil( Math.random() * totalCount ); document.body.background = 'background/'+ num +'.jpg'; document.body.style.backgroundSize = "cover"; } else { console.log("Other"); } </script>
Fabrício Montenegro
18,723 PointsMeh, I messed up. I meant to say 3 backticks (```)
1 Answer
Jeff Busch
19,287 PointsHi Gregg,
Just looking at this code your problem is a missing closing curly bracket after the function.
Jeff
Fabrício Montenegro
18,723 PointsFabrício Montenegro
18,723 PointsHey Gregg, try using the proper markdown next time. 3 ` gives you a code block.