

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 7
click for more info
Not enough gems
Cost: 6 gems
1: Arrays in Go
incomplete
2: Slices in Go
incomplete
3: Slices Review
incomplete
4: Make
incomplete
5: Len and Cap Review
incomplete
6: Variadic
incomplete
7: Append
incomplete
8: Range
incomplete
9: Slice of Slices
incomplete
10: Tricky Slices
incomplete
11: Message Filter
incomplete
12: Password Strength
incomplete
13: Message Tagger
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
Slices can hold other slices, effectively creating a matrix, or a 2D slice.
rows := [][]int{}
rows = append(rows, []int{1, 2, 3})
rows = append(rows, []int{4, 5, 6})
fmt.Println(rows)
// [[1 2 3] [4 5 6]]
We support various visualization dashboards on Textio that display message analytics to our users. The UI for our graphs and charts is built on top of a grid system. Let's build some grid logic.
Complete the createMatrix function. It takes a number of rows and columns and returns a 2D slice of integers. The value of each cell is i * j where i and j are the indexes of the row and column respectively. Basically, we're building a multiplication chart.
For example, a 5x10 matrix, produced from calling createMatrix(5, 10), would look like this:
[0 0 0 0 0 0 0 0 0 0]
[0 1 2 3 4 5 6 7 8 9]
[0 2 4 6 8 10 12 14 16 18]
[0 3 6 9 12 15 18 21 24 27]
[0 4 8 12 16 20 24 28 32 36]