I have a variable
link = 'dog.jpg'
How do I write code to change link to = dog.webm
instead?
I've tried link.text.replace('jpg', 'webm');
but it has no effect?
I have a variable
link = 'dog.jpg'
How do I write code to change link to = dog.webm
instead?
I've tried link.text.replace('jpg', 'webm');
but it has no effect?
You need to make an actual assignment back to the link
variable:
link = link.replace('jpg', 'webm');
But actually, a regex replacement targeting only JPEG extensions would be probably be safer here:
link = link.replace(/\.jpg$/, '.webm');
If you want to Replace Text Then you need to try this,
let link = 'dog.jpg'
link.replace('jpg', 'webm')
you don't need to write link.text.replace
It will help you.