0

I stored user's input in theDate variable but when putting at as argument in Date its not working. Is it because of its scope?

https://code.sololearn.com/W8hMvX0KXj4t/?ref=app

5th Jun 2021, 8:38 AM
dheeraj gupta
dheeraj gupta - avatar
4 Answers
+ 1
Yes, because theDate has a function level scope.
5th Jun 2021, 9:21 AM
Avinesh
Avinesh - avatar
+ 1
var theDate = ""; $(document).ready(function(){ // Get value on button click and show alert $("#myBtn").click(function(){ var dd = $('#date').val(); var mm=$('#month').val(); var yy=$('#year').val(); var h=$('#hours').val(); var m=$('#minutes').val(); var s=$('#seconds').val(); theDate+=dd+mm+yy+" "+h+":"+m+":"+s; }); }); var countDownDate = new Date(theDate).getTime();
5th Jun 2021, 10:54 AM
Avinesh
Avinesh - avatar
0
How do I solve it?
5th Jun 2021, 10:48 AM
dheeraj gupta
dheeraj gupta - avatar
0
Not working Avinesh
6th Jun 2021, 11:00 AM
dheeraj gupta
dheeraj gupta - avatar