-
-
Save AliceWonderland/3558f3129b6368f0527e2a0f5bdf7cee to your computer and use it in GitHub Desktop.
4.3 Zoo Inventory created by smillaraaq - https://repl.it/GzMe/8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var myZoo = [ | |
| ["King Kong", ["gorilla", 42]], | |
| ["Nemo", ["fish", 5]], | |
| ["Punxsutawney Phil", ["groundhog", 11]] | |
| ]; | |
| function zooInventory(myZoo){ | |
| var theMessage=""; | |
| for(var i=0; i<myZoo.length;i++){ | |
| var theMessage=""; | |
| var animal=myZoo[i]; | |
| var animalName=myZoo[i][0]; | |
| var animalDetails=animal[1]; | |
| theMessage+=animalName+" the ";// console.log(theMessage); | |
| for(var x=0; x<animalDetails.length; x++){ | |
| if(x===animalDetails.length-1){ | |
| theMessage+=" is "+animalDetails[x]; | |
| }else{ | |
| theMessage+=animalDetails[x]; | |
| } | |
| } | |
| console.log(theMessage); | |
| } | |
| } | |
| zooInventory(myZoo); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment