IHYPRESS PROGRAMMING
Tutorials and JavaScript programs with code and output for beginners
c programming
HOME | ASP | C | CSS | GNUPLOT | HTML | JAVASCRIPT | PERL | PHP | PYTHON | RUBY | SVG
JavaScript ❯ String Properties and Methods
<10>
<script> let myString = "The quick brown fox"; document.write ("The string has " + myString.length + " characters."); myString = myString + " jumped over the lazy dog."; document.write ("<br>The string now has " + myString.length + " characters."); const star = 'Aldebaran'; const constellation = "Taurus"; const sentence = `${star} is a star in the constellation ${constellation}`; document.write("<div style='color:blue;'>" + sentence + "</div>"); </script> <div style="color:Red; margin-top:10px;"> <script> var cities = "Berlin, Hamburg, Munich, Frankfurt, Dresden, Stuttgart"; var cityArray = cities.split(", "); for(let i = 0; i < cityArray.length; ++i){ document.write("<br> City #" + i + " = " + cityArray[i]); } </script> </div> <div style="color:Purple; margin-top:10px;"> <script> var regexp = /bu/; var found = cities.search(regexp); document.write(cities + "<br>"); if(found != -1) document.write("First <b>bu</b> pattern found at position: " + found); else document.write("Pattern not found."); </script> </div> <div style="color:RoyalBlue; margin-top:10px;"> <script> var cities2 = cities.replace(/u/g, "*"); document.write ("Cities: " + cities); document.write ("<br>Modified cities: " + cities2); </script> </div>
Hergestellt in Deutschland / Made in Germany
COPYRIGHT © 2015-2024 IHY PRESS Frankfurt am Main 60329 Deutschland