Skip to content

Instantly share code, notes, and snippets.

View kevjose's full-sized avatar
👨‍💻
zinging

kevin kevjose

👨‍💻
zinging
View GitHub Profile
(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);
/* 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
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++;
}
}
var greeting = 'Hello World';
console.log(greeting);
<!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>