JavaScript Program to Replace String with a number with Algorithm and Pseudocode
JavaScript Program to Replace String with a number with Algorithm and Pseudocode is the today topic of discussion in this tutorial.
Pseudo code of Replacing the String with number
1 2 3 4 5 |
button onclick="replace()"> function replace() { var str = document.getElementById("demo").innerHTML; var res = str.replace("Fourteen", "14"); document.getElementById("demo").innerHTML = res; |
Program to Replace String with number
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
<!DOCTYPE html> <html> <Title>String Replace</Title> <body> <h1>Click the button to replace Fourteen with its numeric form </h1> <h2 id="demo">Independence Day of Pakistan is Fourteen August</h2> <button onclick="replace()">Replace</button> <script> function replace() { var str = document.getElementById("demo").innerHTML; var res = str.replace("Fourteen", "14"); document.getElementById("demo").innerHTML = res; } </script> </body> </html> |