@@ -113,7 +113,8 @@ These exercises were developed as part of:
113113| 9 | [ Display products] ( #exercise-fn-9-display-products ) | ✔️ | [ Solution] ( ./functions-exercises/09_displayProduct.js ) |
114114| 10 | [ Song '99 Bottles of Beer'] ( #exercise-fn-10-song-99-bottles ) | ✔️ | [ Solution] ( ./functions-exercises/10_song99bottles.js ) |
115115| 11 | [ Deaf Grandma] ( #exercise-fn-11-deaf-grandma ) | ✔️ | [ Solution] ( ./functions-exercises/11_deafGrandma.js ) |
116- | 12 | [ Deaf Grandma ** Pro** ] ( #exercise-fn-12-deaf-grandma-pro ) | ✔️ | [ Solution] ( ./functions-exercises/12_deafGrandmaPro.js ) |
116+ | 12 | [ Deaf Grandma ** Pro** ] ( #exercise-fn-12-deaf-grandma-pro ) | ✔️ | [ Solution] ( ./functions-exercises/12_deafGrandmaPro.js ) |
117+ 117118
118119
119120
@@ -294,7 +295,7 @@ These exercises were developed as part of:
294295
295296![ Status] ( https://img.shields.io/badge/Status-In%20Progress-yellow )
296297
297- * Exercises ** 08-17 **
298+ * Exercises ** 08-18 **
298299 * Started: June 2025
299300 * Completed: June 2025
300301
@@ -320,8 +321,8 @@ These exercises were developed as part of:
320321| 13 | [ Test Results] ( #exercise-arr-13-test-results ) | ✔️ | [ Solution] ( ./array-exercises/13_testResults.js ) |
321322| 14 | [ Discounted Prices] ( #exercise-arr-14-discounted-prices ) | ✔️ | [ Solution] ( ./array-exercises/14_discounted.js ) |
322323| 15 | [ Formatting City Names] ( #exercise-arr-15-formatting-city-names ) | ✔️ | [ Solution] ( ./array-exercises/15_formattingCities.js ) |
323- | 16 | [ Daily Income Analysis] ( #exercise-arr-16-daily-income-analysis ) | ✔️ | [ Solution] ( ./array-exercises/16_incomeAnalysis.js ) |
324- | 17 | [ Game Inventory] ( #exercise-arr-17-game-inventory ) | ⏳ | |
324+ | 16 | [ Daily Income Analysis] ( #exercise-arr-16-daily-income-analysis ) | ✔️ | [ Solution] ( ./array-exercises/16_incomeAnalysis.js ) |
325+ | 17 | [ Game Inventory] ( #exercise-arr-17-game-inventory ) | 🧪✔️ | [ Solution ] ( ./array-exercises/17_gameInventory.js ) |
325326
326327### Detailed Array Exercises Descriptions
327328
@@ -774,23 +775,25 @@ Item name lengths: [5, 6, 6, 3, 6, 3]
774775
775776* Argument: maxLength (number) - the maximum allowed length for item names.
776777
777- Expected Output (for getShortItems(5) with current inventory ):
778+ Expected Output (for getShortItems(5)):
778779
779780``` javascript
780- Short items (<= 5 chars): Sword, Bow, Map
781- Hint : The filter () method is perfect for this .
781+ Short items (<= 5 chars): " Bow" , " Map" , " Sword "
782+ 782783```
784+ 💡 ** Hint:** The filter() method is perfect for this.
785+ 783786</details >
784787
785788<details >
786- <summary ><strong >8. Function `calculateTotalValue(itemValues)` | ✨ challenging 🌟 </strong ></summary >
789+ <summary ><strong >8. Function `calculateTotalValue(itemValues)` | challenging ✨ </strong ></summary >
787790
788791
789792* Purpose: Calculates the total "value" of all items currently in the inventory based on a provided map of item values.
790793
791794* Argument: itemValues (object) - an object where keys are item names (strings) and values are their corresponding numeric values (e.g., { 'Sword': 100, 'Potion': 20, 'Arrows': 5, 'Map': 30 }).
792795
793- If an item in the inventory is not found in itemValues, its value should be considered 0.
796+ If an item in the inventory is ** not found** in itemValues, its value should be considered 0.
794797
795798Expected Output (example with provided itemValues):
796799
@@ -803,15 +806,16 @@ Total inventory value: 155 gold
803806</details >
804807
805808<details >
806- <summary ><strong >° Testing your Implementation ° </strong ></summary >
809+ <summary ><strong > Testing your Implementation 🧪 </strong ></summary >
807810
808811
809812After implementing all the functions, add the following code to your .js file (below your function definitions) to test their functionality.
810813
811814This sequence of calls will demonstrate if your inventory manager works correctly.
812815
813816``` javascript
814- let myAdventureInventory = [' Steel Sword' , ' Leather Armor' , ' Health Potion' , ' Magical Map' ];
817+ 818+ let myAdventureInventory = [' Steel sword' , ' Leather armor' , ' Health potion' , ' Magical map' ];
815819
816820console .log (" --- My Adventure Inventory Test ---" );
817821
@@ -820,18 +824,18 @@ displayInventory(myAdventureInventory);
820824
821825console .log (" Adding New Gear..." );
822826addItem (myAdventureInventory, ' Elixir of Life' );
823- addItem (myAdventureInventory, ' Magical Map ' ); // This should fail gracefully
827+ addItem (myAdventureInventory, ' Magical map ' ); // This should fail gracefully
824828addItem (myAdventureInventory, ' Rope' );
825829
826830console .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 ' );
831+ removeItem (myAdventureInventory, ' Leather armor ' );
832+ removeItem (myAdventureInventory, ' Rusty dagger ' ); // This should fail as it's not present
833+ removeItem (myAdventureInventory, ' Health potion ' );
830834
831835console .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
836+ hasItem (myAdventureInventory, ' Steel sword ' );
837+ hasItem (myAdventureInventory, ' Elixir of life ' );
838+ hasItem (myAdventureInventory, ' Health potion ' ); // This should fail as it was removed
835839
836840console .log (" Sorting My Inventory..." );
837841sortInventory (myAdventureInventory);
@@ -844,72 +848,67 @@ console.log(`Short items array returned: ${myShortItems}`);
844848
845849console .log (" Calculating Total Value..." );
846850const myPriceList = {
847- ' Steel Sword ' : 150 ,
848- ' Leather Armor ' : 75 ,
849- ' Health Potion ' : 20 ,
850- ' Magical Map ' : 50 ,
851- ' Elixir of Life ' : 200 ,
851+ ' Steel sword ' : 150 ,
852+ ' Leather armor ' : 75 ,
853+ ' Health potion ' : 20 ,
854+ ' Magical map ' : 50 ,
855+ ' Elixir of life ' : 200 ,
852856 ' Rope' : 5
853857};
854- const myTotalValue = calculateTotalValue (myAdventureInventory, myPriceList);
858+ const myTotalValue = calculateTotalValue (myPriceList);
855859console .log (` Total inventory value: ${ myTotalValue} gold` );
856860
857861console .log (" My Adventure Inventory: Final State" );
858862displayInventory (myAdventureInventory);
859- ```
860863
864+ ```
861865
862866Expected Output:
863867
864868``` javascript
865869-- - My Adventure Inventory Test -- -
866870My Adventure Inventory: Initial State
867- Your inventory: Steel Sword,Leather Armor,Health Potion,Magical Map
868- 871+ [📜] Your inventory: (4 ) [' Steel sword' , ' Leather armor' , ' Health potion' , ' Magical map' ]
869872Adding 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- 873+ Adding Elixir of Life... ⏳
874+ [➕] Item added: Elixir of life
875+ [📜] Your inventory: (5 ) [' Steel sword' , ' Leather armor' , ' Health potion' , ' Magical map' , ' Elixir of life' ]
876+ Adding Magical map... ⏳
877+ [❗] You already have Magical map in your inventory.
878+ [📜] Your inventory: (5 ) [' Steel sword' , ' Leather armor' , ' Health potion' , ' Magical map' , ' Elixir of life' ]
879+ Adding Rope... ⏳
880+ [➕] Item added: Rope
881+ [📜] Your inventory: (6 ) [' Steel sword' , ' Leather armor' , ' Health potion' , ' Magical map' , ' Elixir of life' , ' Rope' ]
880882Removing 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- 883+ Attempting to remove Leather armor... ⏳
884+ [➖] Leather armor removed from inventory.
885+ [📜] Your inventory: (5 ) [' Steel sword' , ' Health potion' , ' Magical map' , ' Elixir of life' , ' Rope' ]
886+ Attempting to remove Rusty dagger... ⏳
887+ [❗] Item Rusty dagger not found in inventory.
888+ [📜] Your inventory: (5 ) [' Steel sword' , ' Health potion' , ' Magical map' , ' Elixir of life' , ' Rope' ]
889+ Attempting to remove Health potion... ⏳
890+ [➖] Health potion removed from inventory.
891+ [📜] Your inventory: (4 ) [' Steel sword' , ' Magical map' , ' Elixir of life' , ' Rope' ]
891892Is 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- 893+ [✔️] You have Steel sword in your inventory.
894+ [✔️] You have Elixir of life in your inventory.
895+ [❌] You do not have Health potion in your inventory.
896896Sorting My Inventory...
897- Sorting inventory...
898- Your inventory: Elixir of Life,Magical Map ,Rope,Steel Sword
899- 897+ Sorting inventory... ⏳
898+ [📜] Your inventory: Elixir of life,Magical map,Rope,Steel sword
900899Analyzing 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
900+ [📜] Your inventory: Elixir of life,Magical map,Rope,Steel sword
901+ Item name lengths: (4 ) [14 , 11 , 4 , 11 ]
902+ Item lengths array returned: 14 ,11 ,4 ,11
903+ Short items (<= 6 chars): [' Rope' ]
904904Short items array returned: Rope
905- 906905Calculating Total Value...
907- Calculating total inventory value...
908- Total inventory value: 355 gold
909- Total inventory value returned : 355 gold
910- 906+ Calculating total inventory value... ⏳
907+ [💰] Total inventory value: 405 gold
908+ [📜] Your inventory: Elixir of life,Magical map,Rope,Steel sword
909+ Total inventory value : 405 gold
911910My Adventure Inventory: Final State
912- Your inventory: Elixir of Life, Magical Map , Rope, Steel Sword
911+ [📜] Your inventory: ( 4 ) [ ' Elixir of life ' , ' Magical map ' , ' Rope' , ' Steel sword ' ]
913912```
914913</details >
915914
@@ -931,4 +930,3 @@ This repository contains exercises & assignments with some content sourced from
931930
932931
933932
934- [ Up] ( #table-of-contents- )
0 commit comments