by Peter Jaric
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:
three.plus.two === 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 = forty.plus.two;
All code can be found at Github: https://github.com/peterjaric/mathemancy.js
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!