Created
June 10, 2024 23:34
-
-
Save Ephellon/bfe147059b5620312265d9b1f429d849 to your computer and use it in GitHub Desktop.
Do the following... Needs proper documentation (see JSDoc)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ******** // | |
let total = 0; | |
// Write a function called `add` that does the following: | |
// 1) Takes an argument (`n`) and adds it to the `total` | |
// 2) Can be called using a running parenthesis chain (see examples) | |
// These should increase the total... | |
add(); // total = 1 | |
add(1)(2)(3)(4)(5); // total = 16 | |
add(-1)(+1); // total = 16 | |
// ******** // | |
// Create a class called `Todo` that does the following: | |
// 1) Takes arguments: `name`, `date`, and `complete` | |
// a) `name` should be a string but, can be any type; coerce this into a string | |
// b) `date` **must** be a Date; if a date is not given, throw an error | |
// c) `complete` should be a boolean; coerce this into a boolean | |
// 2) Has two (2) static methods: | |
// a) `markAs` which takes 2 arguments: a Todo object and a completion status, then changes the Todo's status to the given one | |
// b) `remove` which takes 1 argument: a Todo object, then removes it | |
// 3) Has four (4) prototype methods: | |
// a) `markComplete` which marks the item complete | |
// b) `markIncomplete` whcih marks the item incomplete | |
// c) `dueDate` which changes the item's due date if a new date is given, otherwise it returns the due date | |
// d) `description` which adds a description to the item if a new one is given, otherwise it returns the description | |
let getHairCut = new Todo('Haircut', new Date('12-12-2024'), false); | |
gethairCut.description(); // undefined | |
gethairCut.description("Xmas haircut!"); // "Xmas haircut!" | |
gethairCut.description(); // "Xmas haircut!" | |
getHairCut.dueDate(); // Thursday, December 12, 2024 | |
getHairCut.name; // "Haircut" |
dskw1
commented
Jun 11, 2024
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment