Replace a function that does not replace

I used some documents to use the JavaScript replace function and didn’t change anything. Errors do not occur. Any idea what I'm doing wrong? The variable is extracted from XML - perhaps it needs to be distinguished as a string or something else?

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 meaning of the thumb should look like this:

http://b.vimeocdn.com/ts/160/895/160895498_200.jpg

Is there a better way to find and replace things?

+5
source share
2 answers

Assign the value back to thumb.

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

Try:

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

All Articles