JSFiddle - React, Tailwind, and code Playground

by Vladimir

JavaScript

function ToDoItem(Text, date, isDone = false)
{

	if (!(typeof(Text) == "string") || (Text.localeCompare("") == 0))
	{
		return undefined;

	}
	if(!(date instanceof Date))
		return("please enter A valid Date");
	
	date.setUTCMonth(date.getUTCMonth()-1)
	console.log(date.getUTCMonth());
	this.Text = Text;			//type of String
	this.date = date;			//type of Date
	this.isDone = isDone;		//type of boolean
	
	if(typeof this.postpone != "function") 
	{
		ToDoItem.prototype.toString = function()
		{
			if ( typeof(this) == "undefined")
			{
			alert("here");

				return;
			}
			return ("Task: "  + this.Text + ", Date:" + this.date + " , isDone: " + this.isDone);
		}
		
		ToDoItem.prototype.isOutOfDate = function(now)
		{
			if(now == undefined || !(now instanceof Date) )
					return "please enter Date";
				
			if(now < this.date)			
				return true;
			return false;
		}

		ToDoItem.prototype.postpone = function(days)
		{
			if(days == undefined || !(typeof(days) == "number"))
				return "please enter a number";
			if(days < 0)
				return "this is negative number"; 
			if(days >= 0)
			{
				var oldDay = this.date.getDate();
				this.date.setDate(oldDay + days);
			}
		}	
	}
}
	
function ToDoList() {
	this.List = [];
	if(typeof this.addItem != "function") 
	{
		ToDoList.prototype.constructor = ToDoList;

	}
}
ToDoList.prototype.toString = function() {
			var str = "";
			for(var i=0;i<this.List.length;i++)
				str += i+1 + ":" + this.List[i].toString() + "\n"; 			
			return str;
		}
ToDoList.prototype.getForDate = function(date)	{
			if(date == undefined || !(date instanceof Date))
				return "please enter Date";
			
			var arr = [];
			var capacity = 0;
			
			for(var i=0;i<this.List.length;i++)
				if( (this.List[i].date.getDate() == date.getDate()) && (this.List[i].date.getMonth() == date.getMonth()) && (this.List[i].date.getYear() == date.getYear()) )
					arr[capacity++] = this.List[i];
				
			
			return arr;
		}
ToDoList.prototype.getOutOfDate = function()...