Last active
April 24, 2021 15:33
-
-
Save phette23/9190458 to your computer and use it in GitHub Desktop.
A few JavaScript One-Liners
This file contains 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
// taken from https://medium.com/html5-css3/7c80a4b731f8 | |
// and expanded, unreadable one-liners are kind of pointless | |
//pad zeroes | |
function pad(num) { | |
return ('0' + num).split('').reverse().splice(0,2).reverse().join('') | |
} | |
// get page query params | |
var qp = document.location.search.replace(/(^\?)/,'') | |
.split("&").map( function (n) { | |
return n=n.split('='), this[n[0]]=n[1], this; | |
}.bind({}))[0]; | |
// my own | |
// return random member of array | |
rand = function (array) { | |
return array[Math.floor(Math.random() * array.length)]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment