Code newbie here stuck on a seemingly easy problem.
Say I want to add an ? to the beginning and ending of all elements in an array. so if my array is ["abc","def"] , my output would be ["?abc?"," ?def?"].
I tried to use for loop / for each but the error message is saying : Cannot use mutating member on immutable value: 'word' is a 'let' constant
This is what I had so far and did not workout:
var array = ["abc","def"]
array.forEach { (word) in
word.insert("?", at: word.startIndex)
word.insert("?", at: word.endIndex) }