Skip to content

Instantly share code, notes, and snippets.

View DanH42's full-sized avatar

Dan Hlavenka DanH42

View GitHub Profile
@DanH42
DanH42 / adding-in-javascript.jquery.js
Last active July 7, 2018 05:27 — forked from ceci21/adding-in-javascript.js
let's do math but with jQuery
(function($) {
$.fn.add = function(sep = " = ") {
(function($this) {
const re = /([0-9]+)/g;
const n1 = re.exec($this.text());
const n2 = re.exec($this.text());
if ((n1 && n2) === null) return function(){};
const a = parseInt(n1[0]);
const b = parseInt(n2[0]);