I need a simple function for creating new array from existing array. I have many arrays and it is not one-time operation, so I need a function.
Inside the function all is working fine and new array contains values I need. But after I execute it new array still is empty.
What could be a problem?
$(document).ready(function() {
const $myArrOne = [
'img/cakes/cake1.jpg',
'img/cakes/cake2.jpg',
'img/cakes/cake3.jpg',
];
let $myArrTwo = [];
const $myFunc = function(arrOne, arrTwo) {
arrTwo = arrOne.map(item => {
return (item.slice(0, -4) + '-small.jpg');
});
return arrTwo;
};
$myFunc($myArrOne, $myArrTwo);
console.log($myArrTwo);
}