rbi-learning / Today-I-Learned

1 stars 0 forks source link

Today I Learned 8/18 #153

Open amatheus000 opened 4 years ago

amatheus000 commented 4 years ago

Morning Exercise

We learned how to set up a button that keeps adding products when pressing the add button.

function addToCart(event){ const theButtonThatGotClicked = event.currentTarget const priceId = theButtonThatGotClicked.closest('[data-priceid]').dataset.priceid if (cart[priceId]) { cart[priceId] += 1 // This code allows to add 1 item everytime it is clicked }else { cart[priceId] = 1

We used this similar function to set up a subtract button from the cart dialog:

function subtractFromCart(event){ const theButtonThatGotClicked = event.currentTarget const priceId = theButtonThatGotClicked.closest('[data-priceid]').dataset.priceid if (cart[priceId] > 1){ //This line is telling us that it will keep deleting items until ther is 1 item left cart[priceId] -= 1 }else{ delete cart[priceId] //In case there they delete the 1 item lefrt, the whole item should be removed fromn the cart dialog

Afternoon

We learned the concept of a CMS: which allows the user to store data and have it accessible on another site. It is very useful for non-developers to update apps without the use of developers.

We learned how to set up Sanity in our machines and define the Schema with the format it should have for our BK Categories Menu.