json will not accept a variable storing a url after using a .replace() on that variable (myimg) as seen below:

$.get('http://api.soundcloud.com/resolve.json?url=https://soundcloud.com/'+user_name+'/tracks&client_id='+my_client_id, function (result) { for (var i = 0; i < result.length; i++) { var myimg = result[i].artwork_url; var myimg = myimg.replace('-large', '-t500x500'); //problem line of code making the variable not usable in json object below. trackdata[i] = { title: result[i].title, mp3: result[i].stream_url + '?client_id=' + my_client_id, url: result[i].permalink_url, poster: myimg, // not working if i use .replace() on myimg var above , works without it sc: "true" } } for (i = 0; i < trackdata.length; i++) { playlist.push(trackdata[i]); } });

If I take out this line :

var myimg = myimg.replace('-large', '-t500x500');

The variable will work,however I would like to replace a string in the url before passing it to the json object. This will allow me to update the url to a higher quality image detailed in this question: Soundcloud 500x500 artwork by default