From 4c2dfe71cb69bd879223fc897a8002db67863ebc Mon Sep 17 00:00:00 2001 From: Ben Park Date: Sat, 21 Apr 2018 07:41:35 -0400 Subject: [PATCH] Learn to use the index number as a reference point for different entry items --- .../xcshareddata/IDEWorkspaceChecks.plist | 8 ++++++++ ArrayChallenge/ShoppingList.swift | 12 ++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 ArrayChallenge.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist 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..9e6b764 100644 --- a/ArrayChallenge/ShoppingList.swift +++ b/ArrayChallenge/ShoppingList.swift @@ -12,10 +12,18 @@ class ShoppingList { func createShoppingList(withItems items: [String], amountOfEachItem amounts: [String]) -> [String] { - - // Implement this function + var shoppingList: [String] = [] + for (index, item) in items.enumerated() { + + var something = amounts[index] + + var somethingElse = "\(index+1). \(item)(\(something))" + + shoppingList.append(somethingElse) + } + return shoppingList }