How to replace an apostrophe in a string in Javascript?

前端 未结 3 1899
没有蜡笔的小新
没有蜡笔的小新 2021-02-07 19:43

Given a string in Javacript, such as

var str = \"this\'s kelly\";

I want to replace the apostrophe (\') with another character. Here is what I\

3条回答
  •  长情又很酷
    2021-02-07 20:17

    str = str.replace("'", "A");

    Your running the function but not assigning it to anything again so the var remains unchanged

提交回复
热议问题