@@ -85,8 +85,8 @@ These exercises were developed as part of:
8585![ Status] ( https://img.shields.io/badge/Status-Complete-brightgreen )
8686
8787 * Exercises ** 10 - 11**
88- * Started: June 2025
89- * Completed: June 2025
88+ * Started: July 2025
89+ * Completed: July 2025
9090
9191** III. Additional Practice Exercises**
9292
@@ -244,7 +244,7 @@ Write a program which prints out the lyrics to that beloved classic, that field-
244244
245245 - You can't stop talking to grandma until you shout "* BYE* ".
246246
247- 💡 ** Hint** : Don't forget 'BYE' is not the same as 'BYE ' or ' BYE '!
247+ 💡 ** Hint** : Don't forget 'BYE' is not the same as 'BYE ' or ' BYE '.
248248 Use ` trim() ` .
249249</details >
250250
@@ -269,7 +269,7 @@ Write a program which prints out the lyrics to that beloved classic, that field-
269269 • ** Saying Bye to Grandma:**
270270 You can't stop talking to grandma until you shout 'BYE' 3 times ** in a row** (If you say 'BYE' and then anything else, it won't count).
271271
272- 💡 ** Hint** : Don't forget 'BYE' is not the same as 'BYE ' or ' BYE '! Use ` trim() ` .
272+ 💡 ** Hint** : Don't forget 'BYE' is not the same as 'BYE ' or ' BYE '. Use ` trim() ` .
273273
274274 ✨ ** Feature:** More phrases stored in arrays that Grandma speaks randomly (depending on the input conditions).
275275</details >
@@ -671,6 +671,7 @@ Expected Output (for adding 'Healing Potion'):
671671
672672``` javascript
673673Adding Healing Potion...
674+ Item added: Healing Potion
674675Your inventory: Sword, Shield, Potion, Bow, Arrows, Map , Healing Potion
675676```
676677
@@ -810,55 +811,105 @@ After implementing all the functions, add the following code to your .js file (b
810811This sequence of calls will demonstrate if your inventory manager works correctly.
811812
812813``` javascript
813- console .log (" --- Initial Inventory ---" );
814- displayInventory ();
815- 816- console .log (" \n --- Scenario 1: Adding Items ---" );
817- addItem (' Healing Potion' ); // Add a new item
818- addItem (' Map' ); // Try to add a duplicate item
819- addItem (' Gold Coins' ); // Add another new item
820- 821- console .log (" \n --- Scenario 2: Removing Items ---" );
822- removeItem (' Shield' ); // Remove an existing item
823- removeItem (' NonExistentItem' ); // Try to remove a non-existent item
824- removeItem (' Arrows' ); // Remove another existing item
825- 826- console .log (" \n --- Scenario 3: Checking for Items ---" );
827- hasItem (' Sword' ); // Check for an existing item
828- hasItem (' Gold Coins' ); // Check for a newly added item
829- hasItem (' Magic Orb' ); // Check for a non-existent item
830- 831- console .log (" \n --- Scenario 4: Sorting Inventory ---" );
832- sortInventory ();
833- 834- console .log (" \n --- Scenario 5: Item Transformations (map) ---" );
835- const lengths = getItemLengths (); // Call the function, it should log its output internally
836- console .log (` Item lengths array returned: ${ lengths} ` );
837- 838- console .log (" \n --- Scenario 6: Item Filtering (filter) ---" );
839- const shortItems = getShortItems (5 ); // Call the function, it should log its output internally
840- console .log (` Short items array returned: ${ shortItems} ` );
841- const veryShortItems = getShortItems (3 );
842- console .log (` Very short items array returned: ${ veryShortItems} ` );
843- 844- 845- console .log (" \n --- Scenario 7: Calculating Total Value (reduce) ---" );
846- const itemPriceList = {
847- ' Sword' : 100 ,
848- ' Shield' : 80 , // Note: Shield might be removed earlier depending on exact test order
849- ' Potion' : 20 ,
850- ' Bow' : 70 ,
851- ' Arrows' : 5 ,
852- ' Map' : 30 ,
853- ' Healing Potion' : 25 ,
854- ' Gold Coins' : 10
855- // NonExistentItem and Magic Orb have 0 value as they are not here
814+ let myAdventureInventory = [' Steel Sword' , ' Leather Armor' , ' Health Potion' , ' Magical Map' ];
815+ 816+ console .log (" --- My Adventure Inventory Test ---" );
817+ 818+ console .log (" My Adventure Inventory: Initial State" );
819+ displayInventory (myAdventureInventory);
820+ 821+ console .log (" Adding New Gear..." );
822+ addItem (myAdventureInventory, ' Elixir of Life' );
823+ addItem (myAdventureInventory, ' Magical Map' ); // This should fail gracefully
824+ addItem (myAdventureInventory, ' Rope' );
825+ 826+ console .log (" Removing Unwanted Items..." );
827+ removeItem (myAdventureInventory, ' Leather Armor' );
828+ removeItem (myAdventureInventory, ' Rusty Dagger' ); // This should fail as it's not present
829+ removeItem (myAdventureInventory, ' Health Potion' );
830+ 831+ console .log (" Is the Gear Present?" );
832+ hasItem (myAdventureInventory, ' Steel Sword' );
833+ hasItem (myAdventureInventory, ' Elixir of Life' );
834+ hasItem (myAdventureInventory, ' Health Potion' ); // This should fail as it was removed
835+ 836+ console .log (" Sorting My Inventory..." );
837+ sortInventory (myAdventureInventory);
838+ 839+ console .log (" Analyzing Item Data (Map/Filter)..." );
840+ const myLengths = getItemLengths (myAdventureInventory);
841+ console .log (` Item lengths array returned: ${ myLengths} ` );
842+ const myShortItems = getShortItems (myAdventureInventory, 6 );
843+ console .log (` Short items array returned: ${ myShortItems} ` );
844+ 845+ console .log (" Calculating Total Value..." );
846+ const myPriceList = {
847+ ' Steel Sword' : 150 ,
848+ ' Leather Armor' : 75 ,
849+ ' Health Potion' : 20 ,
850+ ' Magical Map' : 50 ,
851+ ' Elixir of Life' : 200 ,
852+ ' Rope' : 5
856853};
857- const totalValue = calculateTotalValue (itemPriceList); // Call the function, it should log its output internally
858- console .log (` Total inventory value returned: ${ totalValue} gold` );
854+ const myTotalValue = calculateTotalValue (myAdventureInventory, myPriceList);
855+ console .log (` Total inventory value: ${ myTotalValue} gold` );
856+ 857+ console .log (" My Adventure Inventory: Final State" );
858+ displayInventory (myAdventureInventory);
859+ ```
860+ 861+ 862+ Expected Output:
863+ 864+ ``` javascript
865+ -- - My Adventure Inventory Test -- -
866+ My Adventure Inventory: Initial State
867+ Your inventory: Steel Sword,Leather Armor,Health Potion,Magical Map
868+ 869+ Adding New Gear...
870+ Adding Elixir of Life...
871+ Item added: Elixir of Life
872+ Your inventory: Steel Sword,Leather Armor,Health Potion,Magical Map ,Elixir of Life
873+ Adding Magical Map ...
874+ You already have Magical Map in your inventory.
875+ Your inventory: Steel Sword,Leather Armor,Health Potion,Magical Map ,Elixir of Life
876+ Adding Rope...
877+ Item added: Rope
878+ Your inventory: Steel Sword,Leather Armor,Health Potion,Magical Map ,Elixir of Life,Rope
879+ 880+ Removing Unwanted Items...
881+ Attempting to remove Leather Armor...
882+ Leather Armor removed from inventory.
883+ Your inventory: Steel Sword,Health Potion,Magical Map ,Elixir of Life,Rope
884+ Attempting to remove Rusty Dagger...
885+ Item Rusty Dagger not found in inventory.
886+ Your inventory: Steel Sword,Health Potion,Magical Map ,Elixir of Life,Rope
887+ Attempting to remove Health Potion...
888+ Health Potion removed from inventory.
889+ Your inventory: Steel Sword,Magical Map ,Elixir of Life,Rope
890+ 891+ Is the Gear Present?
892+ You have Steel Sword in your inventory.
893+ You have Elixir of Life in your inventory.
894+ You do not have Health Potion in your inventory.
895+ 896+ Sorting My Inventory...
897+ Sorting inventory...
898+ Your inventory: Elixir of Life,Magical Map ,Rope,Steel Sword
899+ 900+ Analyzing Item Data (Map / Filter)...
901+ Item name lengths: 14 ,12 ,4 ,11
902+ Item lengths array returned: 14 ,12 ,4 ,11
903+ Short items (<= 6 chars): Rope
904+ Short items array returned: Rope
905+ 906+ Calculating Total Value...
907+ Calculating total inventory value...
908+ Total inventory value: 355 gold
909+ Total inventory value returned: 355 gold
859910
860- console . log ( " \n --- Final Inventory State --- " );
861- displayInventory (); // Display inventory one last time after all operations
911+ My Adventure Inventory: Final State
912+ Your inventory: Elixir of Life,Magical Map ,Rope,Steel Sword
862913```
863914</details >
864915
0 commit comments