Need help Operaters

Felix213434

New Coder
Oct 21, 2019
3
0
2
Hello i have an question : exist an way to set an opertator like "*" ,"-", or "+" in a variable like " var operator = -; " ?
 

William

Active Coder
Sep 7, 2019
178
32
38
I could be able to help you with this but I would like it if you could further explain what you mean. I don't really understand any of what you just said. Thanks.
 
  • Like
Reactions: Malcolm

Weboogle

Active Coder
Apr 13, 2019
257
47
28
31
Operators are symbols that represent simple computations. For example, the addition operator is + , subtraction is - , multiplication is * , and division is / . ... When the program runs, each variable is replaced by its current value, and then the operators are applied. The values operators work with are called operands.

C# Variables & Operators with Example: https://www.guru99.com/c-sharp-variables-operator.html
Javascript Operators: https://www.w3schools.com/js/js_operators.asp
Operators - C++ Tutorials: http://www.cplusplus.com/doc/tutorial/operators/
 

William

Active Coder
Sep 7, 2019
178
32
38
You're Variables need to be something like this:
var Operator = 12; or var Operator;.

Your Variable must be declared with a Value or no Value(You can initialize the Value later in the Code). You're Variable can also be in the negatives, so:
var Operator = -12;

Hope this helps.
 

William

Active Coder
Sep 7, 2019
178
32
38
Look, it's really hard to understand what you're saying but from what I'm looking at, you want to declare a Variable and initialize that Variable with an Operator-Symbol such as +, -, * or /, correct? If so, you cannot do such a thing. Symbols are not and cannot be Values in Programming. That applies to every Career, aspect, Paradigm and Programming-Language of CS.

Variables can only take in Words/Letters(Strings) or Values(Integers, Floats and Doubles).
 

joe

Coder
Aug 21, 2019
32
15
8
that wont help cause i now how to use variables but i need a variable to declare to "-" ,"+","*"or"/"
Hi,

I don't think, in JavaScript, you can directly apply an operator as a value to a variable. May be you need to trick it in some way.

Can you explain why exactly you want to assign an operator as a value and what you want to achieve with it?

The question actually sounds interesting