I
I
Ivan Stetsenko2018-02-06 15:19:48
JavaScript
Ivan Stetsenko, 2018-02-06 15:19:48

How to get the sign from a variable?

https://jsfiddle.net/vve3egdy/
the calculate(str) call takes a string like "1 + 2" with a hard-coded "NUM operation NUMBER" format (one space around the operation) and returns the result. How can I get the sign that is stored in the sign property?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Aksentiev, 2018-02-06
@Clark88

eval('1 + 2')

K
kn1ght_t, 2018-02-06
@kn1ght_t

In your code via calc.sign

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question