I am so new on typescript/javascript that I would like to modify each element of array with some function like following code. but I am wondering if there is a more concise/clear way to build my expected array from variable?
const variable = [1,2,3,4,5,6]
function add(a: number, b: number): number {
return a + b;
}
console.log(variable.map((i: number) => {return add(100, i)})) # =>[ 101, 102, 103, 104, 105, 106 ]
returnstatement in map's callback and remove curly brackets if only single expression is needed.