Lost without a map
Given an array of integers, return a new array with each value doubled.
function maps(x: number[]): number[] {
return x.map(y => y * 2);
}
console.log(maps([1,2]);
package main
import "fmt"
func maps(x []int) []int {
for i, v := range x {
x[i] = v * 2
}
return x
}
func main() {
var arr []int = []int{1, 2}
fmt.Println(maps(arr))
}
def maps(x):
return list(map(lambda y: y * 2, x))
print(maps([1,2]))
function maps($x) {
return array_map(function($y) {
return $y * 2;
}, $x);
}
echo maps([1,2]);
Go to Kata
Want us to give you some help with your business? No problem, here's a video on who we can help, and how, along with our calendar so you can book in a call to discuss us working together.
Let's see