MCPcopy Create free account
hub / github.com/LinkedInLearning/javascript-essential-training-2832077 / Backpack

Class Backpack

05_05/Backpack.js:1–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1class Backpack {
2 constructor(
3 name,
4 volume,
5 color,
6 pocketNum,
7 strapLengthL,
8 strapLengthR,
9 lidOpen,
10 dateAcquired,
11 image
12 ) {
13 this.name = name;
14 this.volume = volume;
15 this.color = color;
16 this.pocketNum = pocketNum;
17 this.strapLength = {
18 left: strapLengthL,
19 right: strapLengthR,
20 };
21 this.lidOpen = lidOpen;
22 this.dateAcquired = dateAcquired;
23 this.image = image;
24 }
25 toggleLid(lidStatus) {
26 this.lidOpen = lidStatus;
27 }
28 newStrapLength(lengthLeft, lengthRight) {
29 this.strapLength.left = lengthLeft;
30 this.strapLength.right = lengthRight;
31 }
32 backpackAge() {
33 let now = new Date();
34 let acquired = new Date(this.dateAcquired);
35 let elapsed = now - acquired; // elapsed time in milliseconds
36 let daysSinceAcquired = Math.floor(elapsed / (1000 * 3600 * 24));
37 return daysSinceAcquired;
38 }
39}
40
41export default Backpack;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected