The objective of this assignment is to utilize JavaScript array methods (push, pop, shift, unshift, length, includes, indexOf, splice, slice, Array.isArray, .concat, flat), along with loops, to solve practical problems using real-life datasets.
You're developing an application to manage a grocery shopping list. Your task is to handle and manipulate the shopping list using JavaScript arrays.
"Basmati Rice",
"Masoor Dal",
"Paneer",
"Turmeric Powder",
"Ghee",
"Mangoes",
"Assam Tea",
"Papadums",
"Jaggery"-
Initialize Shopping List:
- Create an array
shoppingListcontaining strings representing items needed for shopping.
- Create an array
-
Add and Remove Items:
- Implement functionality to add items to the shopping list using
pushand remove items usingpop. - Use
shiftandunshiftto manage priority items (move items to the top or remove them).
- Implement functionality to add items to the shopping list using
You're building a system to manage a bookstore's inventory. Your goal is to handle and update the book inventory using JavaScript arrays.
const bookInventory = [
["The God of Small Things", "Arundhati Roy", 10],
["Train to Pakistan", "Khushwant Singh", 15],
["The White Tiger", "Aravind Adiga", 8],
["The Immortals of Meluha", "Amish Tripathi", 20],
["Midnight's Children", "Salman Rushdie", 12]
];-
Initialize Book Inventory:
- Create an array
bookInventorycontaining nested arrays representing book details like title, author, and quantity.
- Create an array
-
Update Inventory:
- Implement functionality to add new books using
concat. - Use
spliceto update book details (change quantity or remove books).
- Implement functionality to add new books using
You're working on a music streaming application. Your task is to manage a playlist and perform operations using JavaScript arrays.
"Chaiyya Chaiyya - Dil Se",
"Maa Tujhe Salaam - A.R. Rahman",
"Kabira - Yeh Jawaani Hai Deewani",
"Kal Ho Naa Ho - Kal Ho Naa Ho",
"Mile Sur Mera Tumhara - Doordarshan"-
Initialize Music Playlist:
- Create an array
musicPlaylistcontaining strings representing song titles.
- Create an array
-
Manipulate Playlist:
- Use loops to display the contents of
musicPlaylist. - Implement
sliceto create a smaller playlist based on specific criteria (e.g., top 5 songs).
- Use loops to display the contents of