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

Class Backpack

Practice/03_12/Backpack.js:8–38  ·  view source on GitHub ↗

* Creating classes: * * Class declaration: class Name {} * Class expression: const Name = class {}

Source from the content-addressed store, hash-verified

6 */
7
8class Backpack {
9 constructor(
10 // Defines parameters:
11 name,
12 volume,
13 color,
14 pocketNum,
15 strapLengthL,
16 strapLengthR,
17 lidOpen
18 ) {
19 // Define properties:
20 this.name = name;
21 this.volume = volume;
22 this.color = color;
23 this.pocketNum = pocketNum;
24 this.strapLength = {
25 left: strapLengthL,
26 right: strapLengthR,
27 };
28 this.lidOpen = lidOpen;
29 }
30 // Add methods like normal functions:
31 toggleLid(lidStatus) {
32 this.lidOpen = lidStatus;
33 }
34 newStrapLength(lengthLeft, lengthRight) {
35 this.strapLength.left = lengthLeft;
36 this.strapLength.right = lengthRight;
37 }
38}
39
40export default Backpack;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected