https://github.com/benhyh/pantry-tracker
https://github.com/benhyh/pantry-tracker
Last synced: 6 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/benhyh/pantry-tracker
- Owner: benhyh
- Created: 2024-08-03T18:09:44.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-08-03T19:02:00.000Z (10 months ago)
- Last Synced: 2024-08-03T20:22:00.234Z (10 months ago)
- Language: JavaScript
- Size: 71.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
This is one of the projects I've built as part of the SWE fellowship program by Headstarter.
# Tech
- Firebase
- Next.js
- React
- GCP (Google Cloud Platform)
- Vercel
- CI/CD## What I learned over the course of the project
### Refined search logic in search bar
```
const filteredItems = pantryItem.filter((item) =>
item.name.toLowerCase().split(' ').some(word =>
word.startsWith(searchQuery.toLowerCase())
)
);
```1. The process:
- Filtering process called on pantryItem array
- Go through each item in the array and apply filtering logic2. Logic:
- Setting it to lowercase so that the search is case-insensitive
3. `.some()`
- some() tests whether at least one element in the array passes the test implemented by the provided function
- return true if it matches the condition, false otherwise4. ` .startsWith(searchQuery.toLowerCase())`
- Checks if the word starts with the lowercase search query
- `.startsWith()` is a string method that determines where the string begins with the characters of a specified string