Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

Level 8 Lesson 3 GO course

I get the message "Have you completed the code to add values to the array?" after clicking Submit. The console output is [1 2 3 4 5]


package main
import "fmt"

func main() {
var intArray [5]int
for i := 0; i < 5; i++ {
intArray[i] = i + 1
}
fmt.Println(intArray)
}
by

3 Answers

sam5epi0l
Please retry with this code and let me know if it still gives an error:
package main
import "fmt"

func main() {
var intArray [5]int
for i := 0; i < 5; i++ {
intArray[i] = i+1
}
fmt.Println(intArray)
}
iamabhishek
Try now, this should work now.
synthlearn
Thanks for the replies, the code I posted now works! :-)

Login / Signup to Answer the Question.