I'm trying to write code that will have a Date be converted to text such as "8:00 AM" not sure where I'm tripping up. I'm using http://labs.codecademy.com/#:workspace to test this code.
var today = new Date();
function calculateMeridian(num){
if (num < 12) {
return "AM";
} else if (num < 24) {
return "PM";
} else if (num > 24)
console.log("calculateMeridian error: num too large, num not in hours");
return "error";
}
function convertMStoText(date) { //input as milliseconds, can't seem to input as actual date
var x = new Date(date);
var h = x.getHours; //change to let
var m = x.getMinutes;
var meridian = calculateMeridian(h);
console.log(h + ":" + m + " " + meridian);
}
convertMStoText(today);
Output:
function getHours() { [native code] }:function getMinutes() { [native code] } error
Output Image: