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

Function Backpack

03_11/script.js:6–31  ·  view source on GitHub ↗

* Create an object constructor function for the Backpack object type. * @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/new

(
  name,
  volume,
  color,
  pocketNum,
  strapLengthL,
  strapLengthR,
  lidOpen
)

Source from the content-addressed store, hash-verified

4 */
5
6function Backpack(
7 name,
8 volume,
9 color,
10 pocketNum,
11 strapLengthL,
12 strapLengthR,
13 lidOpen
14) {
15 this.name = name;
16 this.volume = volume;
17 this.color = color;
18 this.pocketNum = pocketNum;
19 this.strapLength = {
20 left: strapLengthL,
21 right: strapLengthR,
22 };
23 this.lidOpen = lidOpen;
24 this.toggleLid = function (lidStatus) {
25 this.lidOpen = lidStatus;
26 };
27 this.newStrapLength = function (lengthLeft, lengthRight) {
28 this.strapLength.left = lengthLeft;
29 this.strapLength.right = lengthRight;
30 };
31}
32
33const everydayPack = new Backpack(
34 "Everyday Backpack",

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected