|
|
|
|
|
by 6510
1630 days ago
|
|
I guess... x.concat([y*2])
would return the array (but makes a duplicate)Anyway, I find this to be a whole lot more sensible: x=[];
for(y of [1,2,3,4,5]){
if(y%2===1)x.push(y*2)
}
Or even! y=[1,2,3,4,5];
x=[];
// map reduce/flatmap/map/filter etc omg wtf
for( i=0; i < y.length; i++ ){
if( y[i]%2 === 1 ){ x.push( y[i] * 2 ); }
}
I cant even tell what language this is but there is nothing here that needs fixing. |
|