You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
70 lines
1.9 KiB
70 lines
1.9 KiB
<!doctype html> |
|
<html> |
|
<head> |
|
<meta charset="utf-8"> |
|
<meta http-equiv="X-UA-Compatible" content="IE=edge"> |
|
<meta name="viewport" content="width=device-width, initial-scale=1"> |
|
<title>My Learning Website</title> |
|
<link href="/styles/styles.css" rel="stylesheet" type="text/css"> |
|
<link href="/webdevelopment/styles/styles.css" rel="stylesheet" type="text/css"> |
|
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> |
|
<!-- WARNING: Respond.js doesn't work if you view the page via file:// --> |
|
<!--[if lt IE 9]> |
|
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script> |
|
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> |
|
<![endif]--> |
|
</head> |
|
|
|
<body id="homebody"> |
|
<div class="header"> |
|
<h1>The Backpack.js file from Challenge: Build an Advanced Function</h1> |
|
</div> |
|
<pre class="codesample"> |
|
// Set up the Backpack class |
|
class Backpack { |
|
constructor( |
|
id, |
|
name, |
|
volume, |
|
color, |
|
pocketNum, |
|
strapLengthL, |
|
strapLengthR, |
|
lidOpen, |
|
dateAcquired, |
|
image |
|
) { |
|
this.id = id; |
|
this.name = name; |
|
this.volume = volume; |
|
this.color = color; |
|
this.pocketNum = pocketNum; |
|
this.strapLength = { |
|
left: strapLengthL, |
|
right: strapLengthR, |
|
}; |
|
this.lidOpen = lidOpen; |
|
this.dateAcquired = dateAcquired; |
|
this.image = image; |
|
} |
|
toggleLid(lidStatus) { |
|
this.lidOpen = lidStatus; |
|
} |
|
newStrapLength(lengthLeft, lengthRight) { |
|
this.strapLength.left = lengthLeft; |
|
this.strapLength.right = lengthRight; |
|
} |
|
backpackAge() { |
|
let now = new Date(); |
|
let acquired = new Date(this.dateAcquired); |
|
let elapsed = now - acquired; // elapsed time in milliseconds |
|
let daysSinceAcquired = Math.floor(elapsed / (1000 * 3600 * 24)); |
|
return daysSinceAcquired; |
|
} |
|
} |
|
|
|
// Export the Backpack class to be used by other files |
|
export default Backpack; |
|
</pre> |
|
</body> |
|
</html>
|
|
|