Skip to content

Instantly share code, notes, and snippets.

Created April 7, 2017 01:12
Show Gist options
  • Select an option

  • Save anonymous/8f66e654866063cdf50fb7af7f54dffb to your computer and use it in GitHub Desktop.

Select an option

Save anonymous/8f66e654866063cdf50fb7af7f54dffb to your computer and use it in GitHub Desktop.
4.3 Zoo Inventory created by smillaraaq - https://repl.it/GzMe/8
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