Share your repls and programming experiences

← Back to all posts
A simple calculator
h
sojs

A normal calculator. That can do most mathematical functions such as sqrt() and can even run javascript if you enclose it with function(){ //code goes here }
Have fun!

Voters
Pythonier
Acer123
sojs
Comments
hotnewtop
Highwayman

Are you sure it can’t

sojs

@Highwayman I meant plain sqrt(); I tried Math.eval() and

but they both did not work

Highwayman

@sojs it’d more be like

sojs

@Highwayman That is genius. I never thought of that. Thanks!

sojs

@Highwayman Actually, that will not work because eval() only evaluates code in the string and does not use or interact with variables in the global namespace.

Highwayman

@sojs are you sure? That’s the entire point of eval though. It does work, just try it.

sojs