JSFiddle - React, Tailwind, and code Playground

by John Schulz

JavaScript

function setMonthForReal(date, newMonth) {
    document.write('<p>date is '+ date);
    document.write("<br>setting month to " + newMonth);
    date.setMonth(newMonth);
    document.write('<br>date is '+ date);
    document.write("<br>month is now " + date.getMonth());
    if (newMonth != date.getMonth()) {
        document.write(" <span style='color:red'>Um...what!?</span>");
    }
}

var d = new Date();
setMonthForReal(d, 0);
setMonthForReal(d, 1);
setMonthForReal(d, 2);
setMonthForReal(d, 3);