I'm struggling to concatenate my image names in this JavaScript code as a newbie, especially since it's pulling from JSON. Any assistance would be greatly appreciated! Below is the JS code snippet I'm working with:
function log(msg){
console.log(msg)
}
function createImage(file, parent){
var str = file;
var filename = ("photos/" + filename + ".jpg");
var image = new Image();
image.src = filename;
image.style.width = "50px";
image.style.height = "auto";
image.onload = function(){
log('good ' + file );
parent.appendChild(image); //adds the image to the page!
}
image.onerror = function(){
log('not able to load ' + filename );
//parent.appendChild(image);
}
}