What am I going wrong here? I'm trying to convert a string to an integer to use in addition.
I have an image with a class of portfolio and a src of images/portfolio-images/gbn1.jpg
The first alert says the value of imageInt is 1, but the second alert says the value of newImg is gbn11.jpg when I'm trying to get gbn2.jpg.
I am posting my code below:
var mainImg = $('.active-more').closest(".container").find("img.portfolio:first").attr("src");
var nofilename = mainImg.replace("images/portfolio-images/","");
nofilename = nofilename.replace(".jpg","");
var imageString = nofilename.replace(/[A-Za-z$-]/g, "");
var imageInt = parseInt(imageString, 10);
var imageProject = nofilename.replace(/\d+/g, '');
alert(imageInt);
var newImg= imageProject + imageInt + 1 + ".jpg";
alert(newImg);