50.8k views
1 vote
After the following code runs, what will be the value of result? var x = 30; function get () { return x; } function set (value) { x = value; } set(10); var result = get(20);

User Haseeb
by
6.3k points

1 Answer

2 votes

Answer:

Null

Step-by-step explanation:

It entirely depends on the language you are using to implement this.

But generally by the rule of scope, "result" will return null since get() was not defined to accept any argument, and it neither know the global "x" not defined it's own x in the function.

User Ambili B Menon
by
6.6k points