/ Published in: JavaScript
These are essential javascript techniques every javascriptr must know. I will be adding more to this list, let me know what you'd like to see. Thanks!
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<script type="text/javascript"> //replace a string var astring = "Peter picked a peck of pickled peppers, how many peppers did Peter Piper pick?"; console.log(astring.replace(/peppers/gi,"parsnips")); //truncate a string console.log(astring.substr(0,30)); //display numbers 0 -> 100 skipping 2 for(var i = 0; i<=100; i+=2){ if(i == 0) console.log(0); else console.log(i-1) } </script>