Riddle #2
JavaScript
/********************
Riddle #2:
1) Variable a is declared with var.
2) Variable b is not declared with var.
3) 'Call A' still returns 15.
4) 'Call B' however, now returns 23 ???
********************/
a = 3;
b = 2;
function line(x) {
var a = 5;
b = 4;
return a*x + b;
}
// Call A:
// still returns 15
b = line(a) - b;
alert(b);
// Call B:
// now returns 23 ???
c = line(a) + b;
alert(c);