Chapter 6 - Slices
Exercise 1: The Slice Operator
Define a printLines
function that takes a slice of strings as a parameter, and prints each element of that slice on a separate line.
Then, in main
, get a slice of the daysOfWeek
array containing just the weekdays: “Monday”, “Tuesday”, “Wednesday”, “Thursday”, and “Friday”. Pass that slice to printLines
.
Solution
Output:
Monday
Tuesday
Wednesday
Thursday
Friday