Replace function not replacing [duplicate]

I followed some documentation to use the JavaScript replace function and it's not changing anything. No errors are thrown. Any idea what I'm doing wrong? The variable is retrieved from XML - maybe it needs to be cast as a string or something?

for (var i = 0, iln = projects.length; i < iln; i++){
    var thumb = projects[i].get('thumb');
    thumb.replace("200.jpg", "640.jpg");
    console.log(thumb) //200.jpg not replaced

The full thumb value should look like this:

Is there a better way to find and replace things?



Assign the value back into thumb.

thumb = thumb.replace("200.jpg", "640.jpg");


thumb = thumb.replace("200.jpg", "640.jpg");


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.