DOMINIC SIMPSON

DOMINIC SIMPSON

Fruit Shop

Fruit Shop screenshot

View app
View GitHub repository

For the fourth project required as part of my application to Founders & Coders, I completed a Fruit Shop Shopping Cart. This was a complicated project to undertake, in which I learned about the Local Storage function in Google Chrome for the first time. The project involved having two HTML pages – Index and Cart – linked to each other, as well as to the JavaScript, which included a products array that linked to each fruit item, for which there was one object.

The displayCart function generated dynamically the items added to cart, along with the price. This led to a number of issues with how the price was displayed, with long non-integer numbers. This was solved using the toFixed method, with an argument of the number two specified. This ensured that the price did not include more than two numerical digits after the decimal. However, there still appeared to be a problem, whereby if the last digit in the two digits after the decimal was zero, it would still only print out the first digit. You can see that with this screenshot of the Cart page:

Fruit shop Cart page screenshot

The first Apple Single item displays correctly in the Price column, but not in the Total, for which the final zero after the decimal is missing (it also displays in a wonky manner compared to the other items, and thus is something of an eyesore). Likewise, the Banana Bunch of Five order, which once again displays correctly in the Price column, but not in the Total. However, as you can see in the Blackberries packet item, this time the Total amount does display correctly, due to it not containing a zero as the second digit after the decimal. So the problem here can be summarised that the code was – and still is – not displaying the second digit after the decimal correctly if that digit is zero. This is something that I did not have time to correctly research and rectify due to time constraints but remains an interesting sticking point.