JSFiddle - React, Tailwind, and code Playground

by Jessie Lau

JavaScript

function checkCoupon(enteredCode, correctCode, currentDate, expirationDate) {
    if (enteredCode !== correctCode) {
        return false;
    }

    return Date.parse(currentDate) <= Date.parse(expirationDate);
}

//console.log(checkMonth('September', 'October'));
console.log(checkCoupon('123', '123', 'September 5, 2014', 'October 1, 2014'));
//console.log(checkCoupon('123a','123','September 5, 2014','October 1, 2014'));