Created
February 20, 2023 18:15
-
-
Save angusgrant/45b489ab3dcdbfcd17d33589f6e13106 to your computer and use it in GitHub Desktop.
week 1 test 2
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Treasure Chest</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<style type="text/css"> | |
body { | |
margin: 0 auto; | |
max-width: 40em; | |
width: 88%; | |
} | |
</style> | |
</head> | |
<body> | |
<h1>Treasure Chest</h1> | |
<p>All of the magic here happens in the console.</p> | |
<script> | |
let TreasureChest = (function () { | |
/** | |
* Create the Constuctor object | |
* @param {Obj} obj the starting total for gold , silver, bronze | |
*/ | |
function Constructor (gold = 0, silver = 0, bronze = 0) { | |
this.gold = gold; | |
this.silver = silver; | |
this.bronze = bronze; | |
} | |
/** | |
* Create the Constuctor method addGold | |
* @param {Number} num the additional Gold to add | |
*/ | |
Constructor.prototype.addGold = function (num) { | |
return this.gold += num; | |
}; | |
/** | |
* Create the Constuctor method addSilver | |
* @param {Number} num the additional Silver to add | |
*/ | |
Constructor.prototype.addSilver = function (num) { | |
return this.silver += num; | |
}; | |
/** | |
* Create the Constuctor method addBronze | |
* @param {Number} num the additional Bronze to add | |
*/ | |
Constructor.prototype.addBronze = function (num) { | |
return this.bronze += num; | |
}; | |
/** | |
* Create the Constuctor method getLoot | |
*/ | |
Constructor.prototype.getLoot = function () { | |
return `Total Swag is: Bronze = ${this.bronze}, Silver = ${this.silver}, Gold = ${this.gold}` | |
} | |
return Constructor; | |
})(); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment