+ 1

Adding with Date object

Why canā€™t i add a number to a number derived from a Date object? Look at line 25 and 26 and explain what i am doing wrong. Please ignore anything that is commented out. https://sololearn.com/compiler-playground/WRX3oPcBfVZ7/?ref=app

12th Jan 2025, 3:01 AM
Zvi
Zvi - avatar
4 Answers
+ 2
Firstly, you need to wrap your entire js code inside window.onload = () => {} Another issue is that d is a constant and you are trying to change its value, if you want to change its value then use let or var keyword.
12th Jan 2025, 5:39 AM
Gulshan Mahawar
Gulshan Mahawar - avatar
+ 1
Gulshan Mahawar i donā€™t beleive i just spent an hour on that! Wow, do i feel dumb.ā˜¹ļøšŸ™„
12th Jan 2025, 5:49 AM
Zvi
Zvi - avatar
+ 1
Ok I fixed it up and even added the window.onload for android users.
12th Jan 2025, 6:06 AM
Zvi
Zvi - avatar
0
Zvi Don't worry, happen sometimes šŸ‘
12th Jan 2025, 8:19 AM
Gulshan Mahawar
Gulshan Mahawar - avatar