+ 1
How could I make leap years counter here? (code is in the descritpion)
https://code.sololearn.com/WLn5TDCBYn6f/#js As you can see, my code is a spaghetti one, I've tried to make a calculator between one and today's date. How would you make a leap years counter? Thanks :)
3 Antworten
+ 1
Check This 😄
https://code.sololearn.com/c2gvkj5Qy7U9/?ref=app
+ 1
@Elie thank you bud, you've saved me from the headaches!
I adjusted the code for the JavaScript, and now its:
var counter=0;
while (yourYear<=currentYear){
var x = (yourYear % 4) == 0;
var y = (yourYear % 100) != 0;
var z = ((yourYear % 100 == 0) && (yourYear % 400 == 0));
if (x && (y || z)){
counter++;
}
yourYear++;
}
+ 1
welcome 😊 nice code 👍