Original post

var name_age map[string]int

name := []string{"david", "avid", "stitches", "killeta", "sskrill"}
age := []int{20, 30, 18, 40, 34}

How do you insert slices name and age into name_age map?

I have tried;

for _, i := range names {
	for _, x := range x {
		name_age = map[string]int{i: x}
	}
}

And also tried

for i := 0; i < len(name); i++ {
	for x := 0; x < len(age); x++ {
		mn = map[string]int{name[i]: age[x]}
	}
}

the output in both loops is map[sskrill:34]

When I use

var name_age_x = make(map[string]int)

for i := 0; i < len(name); i++ {
	for x := 0; x < len(age); x++ {
		name_age_x[name[i]] = age[x]
	}
}

The output is map[avid:34 david:34 killeta:34 sskrill:34 stitches:34] ////Age 34 is repeated in all names… /// Even when I use the range loop the result is the same

How do I get this working properly???

NB::: The order of Items should not be altered/sorted so that the age matches with the names.