diff --git a/javascript.js b/javascript.js index 412e614..9d8991e 100644 --- a/javascript.js +++ b/javascript.js @@ -10,38 +10,29 @@ var woolOwners = [ "location": "down the lane" } ]; - - -var bags = haveYouAnyWool; - var haveYouAnyWool = function() { for (var i = 0; i < woolOwners.length; i++) { - var totalBags = totalBags + i; - } - return (i); + var totalBags = i; + totalBags++; } + return totalBags; }; - - +var bags = haveYouAnyWool(); function baabaaBlackSheep() { console.log("BaaBaa BlackSheep have you any wool?"); if (bags > 0) { - console.log("yes sir, yes sir " + totalBags + " bags full"); + console.log("yes sir, yes sir " + bags + " bags full"); } } - function oneForMy() { for (var i = 0; i < 2; i++) { - people = Object.keys(woolOwners); - var person = people.toString(); + people = Object.keys(woolOwners[i]); + var person = people.toString(); console.log("one for my " + person); } } - baabaaBlackSheep(); oneForMy(); - var boy = Object.keys(woolOwners[2]); -var littleBoy = boy[2]; - -var whereHeLives = littleBoy.location; +var littleBoy = boy[0]; +var whereHeLives = woolOwners[2].location; console.log("one for the " + littleBoy + " that lives " + whereHeLives);