November 2019
Beginner
804 pages
20h 1m
English
Remove everything from the todo-it.ts file. Then, add the definition of the TodoItem class:
class TodoItem {
private readonly _creationTimestamp: number; private readonly _identifier: string;
constructor(private _description: string, identifier?: string) {
this._creationTimestamp = new Date().getTime();
if (identifier) {
this._identifier = identifier;
} else {
// this is just for the example; for any real project, use
// UUIDs instead: https://www.npmjs.com/package/uuid
this._identifier = Math.random().toString(36).substr(2, 9); } } get creationTimestamp(): number { return this._creationTimestamp; } get identifier(): string { return this._identifier; } get description(): string { return this._description; } } ...Read now
Unlock full access