.removeLast()
The .removeLast()
method removes the last element in an array.
Syntax
arrayName.removeLast()
Example
var topBabyNames = ["Sophia", "Liam", "Riley", "Jackson", "Olivia", "Noah"]topBabyNames.removeLast()print(topBabyNames)
This will output:
["Sophia", "Liam", "Riley", "Jackson", "Olivia"]