This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (function theLoop (i) { | |
| setTimeout(function () { | |
| alert("Cheese!"); | |
| if (--i) { // If i > 0, keep going | |
| theLoop(i); // Call the loop again, and pass it the current value of i | |
| } | |
| }, 3000); | |
| })(10); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Remove http:// or https:// or www. from url */ | |
| var protomatch = /^(https?):\/\/(www\.)?/; | |
| var url ="https://www.google.com"; | |
| var b = url.replace(protomatch, ''); | |
| console.log(b); //google.com |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var calculatePercentile = function(arr){ | |
| for (var i = 0; i < arr.length; i++) { | |
| var count = 0; | |
| var start = i; | |
| if (i > 0) { | |
| while (i > 0 && arr[i].value == arr[i - 1].value) { | |
| count++; | |
| i++; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var greeting = 'Hello World'; | |
| console.log(greeting); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>Hello World!</title> | |
| </head> | |
| <body> | |
| <h1>Hello World!</h1> | |
| We are using node.js <script>document.write(process.version)</script>. | |
| </body> | |
| </html> |
NewerOlder