1var myStr = 'this,is,a,test';
2var newStr = myStr.replace(/,/g, '-');
3
4console.log( newStr ); // "this-is-a-test"
1var str = "JavaScript replace method test";
2var res = str.replace("test", "success");
3//res = Javscript replace method success
1const p = 'The quick brown fox jumps over the lazy dog. If the dog reacted, was it really lazy?';
2
3console.log(p.replaceAll('dog', 'monkey'));
4
5// expected output: "The quick brown fox jumps over the lazy monkey. If the monkey reacted, was it really lazy?"
6
7
8
9
1function spinWords(pw){
2 let a = ''
3 if(pw.length <= 5){
4 a +=pw.split("").reverse()
5 console.log(a.replaceAll(',' , ''))
6 }else {
7 console.log("olá")
8 }
9}
10
11let hey = "hello";
12spinWords(hey) // olleh