+ 1

Replace specific string with another string

if text is contain '*' then replce that element '*' with this one '×' how to do that https://code.sololearn.com/W3QQfKvaA3XX/?ref=app

15th Dec 2021, 2:41 AM
EsaKurniawan
3 Réponses
+ 5
Use replaceAll function console.log(text.replaceAll("*", "+"))
15th Dec 2021, 3:00 AM
A͢J
A͢J - avatar
15th Dec 2021, 3:15 AM
EsaKurniawan
+ 3
Use replace func var str = "Sololearn is great"; var result = str.replace("great", "nice"); To replace all add /"str"/g var str = "Sololearn is great"; var result = str.replace("/great/g", "nice");
15th Dec 2021, 10:59 AM
Chigozie Anyaeji 🇳🇬
Chigozie Anyaeji 🇳🇬 - avatar