I have an array of image links contained in variable "foundListings.currentimages" below. On the front end a user can check a "featured" box to select an image to be featured. All of that works well.
However I'm not sure how to move the image found under foundListings.currentimages to the front of the array. (If it's in the front of the array it's featured.)
How would I change the code foundListings.currentimages.splice(index2, 1);
to not remove the item from the array but rather put it first in the array?
Thanks for any help! :)
// SELECTING FEATURED IMAGE
// if any images have been selected for feature, --- add it to front of array
if(req.body.feature && req.body.feature.length) {
for(var i = 0; i < req.body.feature.length; i++) {
var index2 = foundListings.currentimages.indexOf(req.body.feature[i]);
foundListings.currentimages.splice(index2, 1);
}
}
foundListings.save();
}