Kodewick
Start learning →
Starter←→0 / 70

Double the recipe

#029StarterSlicesLoops3 min

The bakery is making a double batch today. The recipe's grams of each ingredient are in grams. Write DoubleRecipe(grams) to return a new slice with every amount doubled, in the same order.

Examples
DoubleRecipe([]int{200, 50, 3})→[400, 100, 6]
DoubleRecipe([]int{})→[]
The functionfunc DoubleRecipe(grams []int) []int
main.go
package main

func DoubleRecipe(grams []int) []int {
	double := make([]int, len(grams))
	for i, g := range grams {
		// your code here: set place i to twice g
	}
	return double
}
Ctrl + Enter runs too
Result

Run tries the examples. When they look right, Submit.