From 8dac28379d1b609603efe513db79645cdd973e7e Mon Sep 17 00:00:00 2001 From: mjanoudy Date: Wed, 26 Sep 2018 20:18:40 +0300 Subject: [PATCH] solved the array challenge using a different method --- .DS_Store | Bin 0 -> 6148 bytes .../xcshareddata/IDEWorkspaceChecks.plist | 8 ++++++++ ArrayChallenge/ShoppingList.swift | 17 +++++++++-------- 3 files changed, 17 insertions(+), 8 deletions(-) create mode 100644 .DS_Store create mode 100644 ArrayChallenge.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..df907271cefe3275fe5a547a14e49c1e75c3fc78 GIT binary patch literal 6148 zcmeHKOG*Pl5PhXt1l(kqWuHLE4aS(9AQvzsAwi-u2!h%5+EaQIUwxDe&c=m;QZ;nF z>h7xQ=?Bw21wiJ{+ZiwcFlJK}H3me72d6H=Sy3#<3AZ?4jU%7GA^Pr9+~A4N8t3o7 z!z1?C;TkX4pv9JUN3Rz5$Ng-zX&*Y@;w$(5{T$ulJja`-N}UWO1Ia)#kPQ4h1A1>! z##fH1lYwL)8Te#C&xgXM*aTKbJ36SW1R#z$Y(iUW35_X%O<;B83`IPY=%ErNhIlx~ zOZYW`)zQNtwled?${)px*y8bQzrw-K%aq2?@sjoU-FX~Eb{vy*-HkJfq%w; zj25fKoSTZf^~?73t}SeLY%1zk)u7Ps{RFV1=g8D1eZHtozb3FcY8D;0aAN)l7$K>W IfnQ+Y9ft!aSpWb4 literal 0 HcmV?d00001 diff --git a/ArrayChallenge.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/ArrayChallenge.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/ArrayChallenge.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/ArrayChallenge/ShoppingList.swift b/ArrayChallenge/ShoppingList.swift index 646e1db..34c3b56 100644 --- a/ArrayChallenge/ShoppingList.swift +++ b/ArrayChallenge/ShoppingList.swift @@ -8,14 +8,15 @@ class ShoppingList { - - - func createShoppingList(withItems items: [String], amountOfEachItem amounts: [String]) -> [String] { - - - // Implement this function - - + + let items = ["Bananas", "Apples", "Eggs", "Rolls"] + let amounts = ["6","4","12","4"] + func createShoppingList(withItems items: [String], amountOfEachItem amounts: [String])->[String] { + var shoppingList: [String] = [] + for (index, item) in items.enumerated() { + shoppingList.insert("\(index+1). \(item)(\(amounts[index]))", at:index) + } + return shoppingList }