Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

243
Vistas
Comparing math operator with string

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)
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

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
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda