I'm starting at web development and trying to create my first web app, a calculator, but I bumped into a bit of a problem.
I wanted an app where the user wrote the operator of the operation that needs to be performed and then the program would check this operator and run the specified equation. I know how to perform this in Python but I cannot use the same approach in JS in an HTML file.
In Python I would do something like this:
a = 4
b = 4
operator = '+'
if operator == '+':
print(a+b)
if operator == '-':
print(a-b)
So I've got it to work. I was not getting the value as I was trying to compare it.
so I was trying with
if (operator == '+'):
equation = value_b + value_a
And it should be
if (operator.value == '+'):
equation = value_b + value_a