Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialabdulmohsen abdullah
Courses Plus Student 352 Pointsi got stuck can get some help
i tried my best
// Enter your code below
var arrayOfInts = [1,2,3,4,5,6]
arrayOfInts.append (7)
arrayOfInts + [8]
let value = arrayOfInts[4]
let discardedValue = array.remove,(at:7)
Sam GGG
5,195 PointsSam GGG
5,195 PointsHi abdulmohsen,
There is a typo that might be causing errors. In your last line you wrote array.remove,(at: 7). Try remove the comma after remove. Also, you need to assign the discarded 6th integer in your array to a constant discardedValue. you discarded the 8th integer by removing index 7. So replace index 7 with 5 which would remove the 6th integer. Hope this helps!
// Enter your code below
//to declare new array of Ints with 6 numbers and assign to variable named arrayOfInts
var arrayOfInts = [1, 2, 3, 4, 5, 6]
//to add value using append method
arrayOfInts.append(7)
// to add another item by concatenating an array. No need to assign it to another variable but that is just what I did
var arrayOfOneInt = [8]
arrayOfInts = arrayOfInts + arrayOfOneInt
// to retrieve 5th item and assign to constant named value:
let value = arrayOfInts[4]
//to remove 6th item and assign result to constant named discardedValue:
let discardedValue = arrayOfInts.remove(at: 5 )