(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
// convert the ip address to a decimal | |
// assumes dotted decimal format for input | |
function convertIpToDecimal(ip) { | |
// a not-perfect regex for checking a valid ip address | |
// It checks for (1) 4 numbers between 0 and 3 digits each separated by dots (IPv4) | |
// or (2) 6 numbers between 0 and 3 digits each separated by dots (IPv6) | |
var ipAddressRegEx = /^(\d{0,3}\.){3}.(\d{0,3})$|^(\d{0,3}\.){5}.(\d{0,3})$/; | |
var valid = ipAddressRegEx.test(ip); | |
if (!valid) { | |
return false; |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
Array.prototype.betterFilter = function(expression) {
var res = [];
for(var idx=0; idx<this.length; idx++){
var currentItem = this[idx];
if(expression(currentItem)){
res.push(currentItem);
}
}
return res;