I like how this map works but I have a suspition that it might be bad practice to use return on every iteration of a loop
Is this a bad practice?
Thank you
const array = [
["Header 1", "Header 2"],
[1, 2],
[3, 4],
];
const mappedArray = array.map((row, index) => {
if (index === 0) {
return row;
} else {
return row.map((value) => value * 2);
}
});
I have tryed searching for an awnser to this but found nothing
>Solution :
This is fine, the way the array.map function works is by calling your function to see how to the map the values.
The main concern would be if you’re calling the variable often, if not I wouldn’t worry about it