JSFiddle - React, Tailwind, and code Playground

by Joshua Koudys

HTML

<body>
    <p id="output">i need to learn!..and fast!</p>
</body>

JavaScript

/*create a date object*/
/*var myBday=new Date();
myBday.setFullYear(1982,5,23);*/

var isItAndrewMcloughlinBirthday = function () {
    var myBirthday = new Date(1982, 5, 23);
    var theinput = input("please enter you date of birth");
    for (var dateA = new Date(); !myBirthday(dateA); dateA.setDate(dateA.getDate() + 1)) {
        if (dateA.getMonth() == myBirthday.getMonth() && dateA.getDate() == myBirthday.getDate()) {
            $("#output").text("happy birthday");
        } else {
            isItAndrewMcloughlinBirthday++;
        }

    }
};
// This is the right place for comparison function, but the loop isn't necessary for this question, that's for q3. You also should be returning a true/false, not writing an output like this. 4/6.
// You also kind of shoved q3 in here, and it's the right basic idea with that loop, so you get 1/2 on that.

var isTodayAndrewMcloughlinBirthday = function () {
    isItAndrewMcloughlinBirthday(new Date());
};
// _almost_ perfect, you just need to write 'return' in front of the call. 5.5/6. This was an easy question to overestimate; it's really quite simple.

isItAndrewMcloughlinBirthday();
// i leached much of this scruipt below, but i am learning from it and making it hybrid to what i need.
var howManyDaysUntilAndrewsBirthday = function () {
    today = new Date();
    var myBday = new Date(today.getFullYear(), 5, 23);
    if (today.getMonth() == 5 && today.getDate() > 23) myBday.setFullYear(myBday.getFullYear() + 1);
    //Set 1 day in milliseconds
    var one_day = 1000 * 60 * 60 * 24;

    //Calculate difference btw the two dates, and convert to days
    alert(Math.ceil((myBday.getTime() - today.getTime()) / (one_day)) +
        " days left until myBday!");
};
// Yes! This code isn't quite going ot work, so I won't give the full bonus, but this is exactly the approach you were meant to take. Dates are silly complex to work with, and as all students were told this was a fully-open book test, so why not use someone...