• Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.
    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

JavaScript 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 = -; " ?
 
D

Deleted member 205

Guest
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: Master Yoda
D

Deleted member 65

Guest
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/
 

Felix213434

New Coder
Oct 21, 2019
3
0
2
i want to make a variable that says
Code:
var operator = -
var operator = +
cause so it doesnt work
 
D

Deleted member 205

Guest
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.
 

Felix213434

New Coder
Oct 21, 2019
3
0
2
that wont help cause i now how to use variables but i need a variable to declare to "-" ,"+","*"or"/"
 
D

Deleted member 205

Guest
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
46
27
18
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