- Fork this repository into your Github account.
- Clone your repo to your machine.
- Create a branch named
make-pottery-{your initials}
. - Do all of your work for Part I on this branch.
In this exercise, your task to build a workflow for making, and firing pottery, and then determining if it should be sold at a craft show.
- Define a function that is responsible for making a piece of pottery.
- The function should output an object that represents a piece of pottery.
- The object should describe its shape, weight, and height.
- The function should take all three of those properties as input to generate the object.
- The function should also add an
id
property to the object whose value is an integer, and each object should have a uniqueid
value. Use a globally-scoped variable and increment it each time an object is created.
- Define a function that is responsible for acting as a kiln. It should take a pottery object as input and also the temperature of the kiln as input. It should add a new property of
fired
with the value oftrue
to the object. It should output the pottery object.- If the temperature of the kiln is above 2200 degrees then the pottery object should have a new property of
cracked
added to it, with a value oftrue
. - If the temperature of the kiln is below, or equal to, 2200 degrees then the pottery object should have a new property of
cracked
added to it, with a value offalse
.
- If the temperature of the kiln is above 2200 degrees then the pottery object should have a new property of
- Define a function that is responsible for determining if a piece of pottery should be sold. Cracked pottery should not be sold, and non-cracked pottery should be sold.
- If the weight of the piece of pottery is over 3, then it should get a
price
property with a value of 40. - If the weight is under 3, its price should be 20.
- If the weight of the piece of pottery is over 3, then it should get a
const potteryToSell = []
// Define your functions
// Create 5 pieces of pottery, some cracked and some not.
// Non-cracked pottery should be added to the collection
// of pottery to sell at the craft show.
When you are done, push your branch to Github, create a pull request and then merge your branch into master
. Then pull the new master down to your machine.
In this exercise, you are going to create HTML representations of the pottery you want to sell at the craft fair and display them on the DOM. Then you will track which ones you sell.
- Create a branch named
sell-pottery-{your initials}
. - Do all of your work on this branch.
- Create a function that outputs an HTML representation of a pottery object. The HTML representation should include a button labeled "Sell". The function should take the pottery object as input.
- Iterate the collection of pottery to sell and create an HTML representation of each one and add that representation to an
<article>
element in your DOM that has anid
ofinventory
. - When you click on the "Sell" button of any piece of pottery, use
window.alert
to present a message in the following format.
You sold a {shape of pottery} for ${price}
Once complete, push your branch to Github, create a pull request and merge your branch into master. Then pull down the new master to your machine.
In this exercise, you are going to use json-server
to expose an API containing JSON representations of pottery items, and then write JavaScript to get data from the API.
- Create an
api
sub-directory in your project directory. - In that directory, create a
pottery.json
file. - In that file, create a
pottery
resource array and create 5 pottery JSON representations in that array. Each one should have all of the properties listed in Part 1 of this exercise. - Start
json-server
. - Instead of building your array from the 3 functions you defined in Part 1, use
fetch
to get the data from your API. - Once you have the data, use it for Part 2 of this exercise.