In python, you can do:
ints = [1, 2, 3]
str_ints = [str(my_int) for my_int in ints]
print(str_ints)
which outputs:
['1', '2', '3']
I want to do something similar using javascript using forEach,
let ints = [1, 2, 3]
str_ints = [ints.forEach(my_int => {return String(my_int)})]
console.log(str_ints)
I would expect the output to be:
Array ['1', '2', '3']
however, the output is
Array[undefined]
Is this sort of array creation not possible in javascript?
forEachinstead of functionality designed for the task you want?