Search code examples
javascriptleap-year

Is it possible to make this code to display 42 years in hours ( including leap years)?


age=42;
days +=(age/4);//leap years
var days= age*365;
var hours= days*24;
var age;
console.log(hours);

This code was provided to me by mimo in one of the lessons but I'm not able to resolve this problem. Can you please help me resolve this inconvenience?


Solution

  • I, too, had a difficult time with this one. However, it was also my fault that I jumped into Making a Website project without learning Javascript first.

    The answer to this is:

    var age;
    age = 42;
    var days = age * 365;
    days += (age / 4); *// Leap years
    var hours = days * 24;
    console.log(hours);