How to use between in JavaScript. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to use between in JavaScript.

Hi sololearner! I was practicing coding and want like example if time is between 7 and 12 o,clock document.write("good morning"); so how can I use it by coding. please help me.....

1st May 2018, 5:14 PM
Ybu
3 Answers
+ 3
use Date Object so example ughhhh think of if condition for first if hours between 7 and 12 right? then code would like hours>7 and hours<12 var d=new Date();//get something that called date object while It's data packed of status if(d.getHours()>7&&d.getHours()<12)document.write("good morning,Wakanda!!");else document.write("Loki dead :(")
1st May 2018, 5:24 PM
Yanothai Chaitawat
Yanothai Chaitawat - avatar
+ 6
Does this help? (The second and the third slide) https://www.sololearn.com/learn/JavaScript/1244/?ref=app
1st May 2018, 5:22 PM
Karan Kumar
Karan Kumar - avatar
0
Thanks I get it as you explained, using && is the solution!
1st May 2018, 5:32 PM
Ybu