Fixing the anonymous struct declaration

Report a typo

Mrs. Puff is learning about structs in Go. She tried to implement an anonymous struct to quickly save the scores of her students after grading their exams. However, she forgot to initialize it with a struct literal and now her program isn't working!

Can you help Mrs. Puff fix her anonymous struct and initialize it properly with the following values: SpongeBob as the student name and 0 as the score?

To solve this task, you don't need to write or modify any code within the main function. The objective of this task is to initialize the grades struct with the previously mentioned values.

Write a program in Go
package main

import "fmt"

func main() {
var grades = struct {
Name string
Score int
}{
// initialize the fields of the anonymous 'grades' struct here
}

a := grades
fmt.Printf("%#v", a)
}
___

Create a free account to access the full topic