Local Storage for shopping cart in Javascript

In a previous exercise class with students, we created a simple shopping cart with JS. Today I had another lecture and I added a localStorage feature to this project. In this version of the project, the added items can persist in the cart after a refresh and we added another file named cart.html that shows the added cart items. You can see the source code of this project in the v2.0.0 tag in this repo: JsShoppingCart ...

May 23, 2022 Ā· 2 min Ā· Hamid

Simple Shopping Cart with pure Javascript

I’m a code mentor and private programming tutor. Today, my student and I were working on event listeners in JS and I tried to teach how to make a simple and minimal shopping cart. If you are learning JS, this could be a good exercise. You can find the code here. And you can see a demo here. In this work, we added our products like this: <div class="product"> <h3>Product one</h3> <p>Price: 2000</p> <button data-id="1" data-price="2000">Add to cart</button> </div> We know that in the real world we do not do this manually and we generate them with loops using data that we have retrieved from a database. ...

May 18, 2022 Ā· 2 min Ā· Hamid

Simple exercise for Javascript Ajax

I have about 4 years of experience working as a private tutor of programming. About five years ago, I published a blog post on my website in Persian language entitled ā€œPrivate Laravel Tutorā€ and people started to call me. I always love teaching people and it was a good opportunity. After a while, the number of students increased and today I have two sessions per day on average. Most of my previous students are now working around the world. ...

May 14, 2022 Ā· 2 min Ā· Hamid