Mathemancy.js – a Framework for Natural Language Arithmetic in JavaScript

by Peter Jaric

A while ago, while I was riding my bike to work, I thought: “Would it possible to make evaluate to 7 in JavaScript?” I wanted to see if it was possible, and with some invaluable help from Mathias Bynens and Ingvar Stepanyan I was able to make it work.

I give you:


With mathemancy.js , you can write your arithmetic expressions using natural language in property access notation (this was the hard part). Great, huh? Some examples: === 3 + 2
two.three.minus.four === 23 - 4

var result = six.dividedBy.two.minus.nine.times.four;
result === 6 / 2 - 9 * 4

Please try it out yourself over at the small test bed I created for this purpose.


It is not possible to write for example minus.two, or just two.

Neither parentheses nor other notation except +, -, * and / is supported.

This won’t work:

var forty = five.times.eight;
var fortytwo =;


All code can be found at Github:

Please feel free to create pull requests! Look at the Limitations section for inspiration. ;)


This is a joke framework of course, but the code works, try it out yourself!