You should pick either passing in all the variables as arguments, or fully using closure - doing a mix of both is confusing, and is going to be the reason for your bug - you have two different cacheArray variables, and you're not assigning the inner one to the outer one.
What does alldates.txt contain?
If it's already an array then you can just do:
var cacheArray = JSON.parse(string).map
(function(item){
return item.replace(/100315/,'$&/thumbs');
});
If the Object.values is needed you can still use map:
var cacheArray = Object.values(alldatesobj).map
(function(item){
return item.replace(/100315/,'$&/thumbs';
});
The $& means whatever is matched (pretty much everyone else uses $0 or \0 but JS has to be awkward).
Also, on a general note, you can't trust console.log in modern browsers - they do not tell you a variable's value at the point when you're logging it but have started looking it up after - you need to use console.log(JSON.stringify(variabletolog)) to freeze it and get a correct report.
EDITED: 30 Oct 2018 23:05 by BOUGHTONP