Console reading assignemnt

Hi guys

im stuck on the console reading assignement

hope you can see the screen shot, if not then how to i enter the following

>>let d = new Date();
>>console.log("Today's date is " + d);

i write the first line >>let d = new Date(); and press enter i get this output: Uncaught SyntaxError: missing ) after argument lis

any guidance please


![41812B6F-65B2-4B3D-BD1F-3AC866AB3281_4_5005_c|690x129](upload://4io8ibIG3ojy0K5b0IjZFLfpKkc.jpeg)

Hi @hasman,
I do not know why you are getting this error. I have tried the exact steps too. Could you also attach screenshots so that we can understand what the issue really is.

Regards
Malik

1 Like

Ah, I see what went wrong. You can only supply a string in the Date() constructor. Do not pass it without decorating it with the string quotes. If you want to pass numbers then you need to separate the date argument with commas. See below.

Your statement would look like – let d = new Date("2/9/2020")
Your statement without string would be – let d = new Date(2020, 2, 9) //year, month, day

Check out this link to see what all formats we can supply to the Date() constructor to receive a proper date object.
https://www.w3schools.com/js/js_dates.asp

Hope this helps.

Happy Learning! :slight_smile:

1 Like

Hi, thanks for that
so when i try that in the console for chrome i still get the same error, i typed this into the chrome console let d = new date(2020,12,9); and pressed enter, still get error

am i doing something wrong ?

, according to the assignment we was meant to do this on the chrome browser

would be helpful if you could screenshot how you are doing it in the chrome console

Hi, since β€œDate()” is a function, it needs to be capital β€œD”. Just put it as Date() and do it.

Hope this helps.

Happy Learning! :slight_smile:

1 Like