Hello,
So my problem is that I’m trying to write a function that allows a user to press a date in the calendar using a button that asks if the user has done exercise on that day through a prompt, to which if the user says yes, then it sets the screen to the log page, and if the user says no, then it sets the screen to the stopwatch page. I’m mostly having issues with the date portion and I need your help. Also, I would like to know what program I write if the user cancels the prompt.
I have tried various things, but it still doesn’t lead me to what I expect, which the result is supposed to be that if the user presses a date that contains the date value, a prompt is supposed to show up. Unfortunately, it shows me either as “TypeError: Cannot read property ‘getDay’ of undefined”. I know that a getDate() method should happen in the program, but I don’t know what to do. Here’s a part of the program that I’m trying to present:
function getDateFromButton(textLabel) {
var day = Date.prototype.getDay();
var dayLabel = dayNames[day];
var userInput;
if (textLabel != "") {
userInput = prompt("Have you exercised today and today only?");
if (dayLabel != "Sunday" || dayLabel != "Saturday" && userInput.includes('No') || userInput.includes('no')) {
setScreen("ExerciseStopwatchScreen");
stopWatch();
}
}
// Write a prompt that asks the user if they did exercise that day.
// If yes, set the screen to the log page.
// If no, set the screen to the stopwatch page.
}