6

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:

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

Is there a better way to find and replace things?

Qantas 94 Heavy
  • 15,410
  • 31
  • 63
  • 82
mheavers
  • 28,595
  • 55
  • 189
  • 291

2 Answers2

15

Assign the value back into thumb.

thumb = thumb.replace("200.jpg", "640.jpg");
agent-j
  • 26,389
  • 5
  • 49
  • 78
4

Try:

thumb = thumb.replace("200.jpg", "640.jpg");
Eystein Bye
  • 4,766
  • 2
  • 19
  • 18