Closed mserykh closed 3 years ago
Short description
const price = 457.00;
const productName = "Socks";
const currencyShort = "$";
const currencyName = "dollar";
const isAvailable = true;
undefined: is used by JS when something went wrong and an error must be thrown
Array: is used to store shopping lists, previous orders, e.g.
const shoppingList = [
{
productName: productName1,
price: price1,
currencyShort: currencyShort1,
quantity: quantity
},
{
productName: productName2,
price: price2,
currencyShort: currencyShort2,
quantity: quantity
}
];
BigInt
for IDs.@dev-experience I decided not to use BigInt and moved product ID to the Number. Also I added another type: Object.
Number
for IDs. IDs are just static values. Even if it looks like number, it should be an integer number. But conceptually, it's just an identifier, not number. I would use string for that.[x] Best practice for naming object properties is camel case (not strings).
console.log(shoppingList['product name']);
console.log(shoppingList.productName);
{
productName: productName,
price: price,
currencyShort: currencyShort,
quantity: quantity,
}
shoppingList
. It's a good candidate to use one more data type. List means that there will be zero or more amount of items, not just one.@dev-experience what do you mean by boring? Can you please explain? And can you please give me a link or hint where I can read more about how to use data types in projects and documentation, how to design applications? And is this really a good task for newbies to programming world?
So, usually it's quite boring:
{ productName: productName, price: price, currencyShort: currencyShort, quantity: quantity, }
@mserykh we'll cover everything later. I consider task as done. Feel free to update the answer again.
@mserykh we'll cover everything later. I consider task as done. Feel free to update the answer again.
@dev-experience I have updated the answer:
Assignment
Data Types Practice
Instructions
Imagine you are building a shopping cart. Write some documentation on the data types that you would need to complete your shopping experience. How did you arrive at your choices?
Rubric