0

I’m trying to teach myself JavaScript. I want to be able to reference a line of code so the system can identify it and register it.

console.log(a * w_discount - a * tax - a)

How do I link the answer of this up to do further coding with it?

Pointy
  • 405,095
  • 59
  • 585
  • 614
  • 4
    Assign the result of the expression to a variable? It's not really clear what you're asking. – Pointy Jan 21 '19 at 20:38
  • The same way you created `a`, `tax`, and `w_discount` – Kevin B Jan 21 '19 at 20:42
  • [Expressions and operators](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators) – adiga Jan 21 '19 at 20:46
  • @Wally it would help us all a lot if you clarified your question a bit: what do you mean by "the answer" (the result of `console.log` or the argument statement) and where do you want to link it exactly? What should be the result, what do you want to achieve by "linking"? Do you maybe have an example in another programming language maybe? – Cherusker Jan 21 '19 at 20:51

2 Answers2

0

try use following code which write stack-trace on console (but look on chrome console not snippet) (you can also use error instead warn)

console.warn('xx');

function test() {
    console.warn('xx');
}

test();
Kamil Kiełczewski
  • 85,173
  • 29
  • 368
  • 345
  • 1
    I'm not sure if this answers the question. Then again, the question is not really clear. Didn't downvote your answer however, that was someone else :P – Cherusker Jan 21 '19 at 20:43
  • 1
    @Cherusker I only guess that may be this is what OP really looking for - but it is blind shot – Kamil Kiełczewski Jan 21 '19 at 20:44
0

Store the expression in a variable as such:

var x_variable = (a * w_discount - a * tax - a)

Then reference it anywhere else.

console.log(x_variable)

You can name the variable anything you want.

Cole
  • 564
  • 1
  • 4
  • 14