operations.js 761 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. const operators = [
  2. {
  3. name: "Soma",
  4. operator: "+",
  5. value: "SUM"
  6. },
  7. {
  8. name: "Subtração",
  9. operator: "-",
  10. value: "MINUS"
  11. },
  12. {
  13. name: "Multiplicação",
  14. operator: "*",
  15. value: "MULTIPLICATION"
  16. },
  17. {
  18. name: "Divisão",
  19. operator: "/",
  20. value: "DIVISION"
  21. },
  22. {
  23. name: "Potência",
  24. operator: "^",
  25. value: "POTENTIATION"
  26. },
  27. {
  28. name: "Raíz Quadrada",
  29. operator: "\u221A",
  30. value: "SQUARE_ROOT"
  31. }
  32. ];
  33. function getOperationByValue(value) {
  34. for (let i = 0; i < operators.length; i++) {
  35. if (operators[i].value === value)
  36. return operators[i];
  37. }
  38. return null;
  39. }