i have this code in java script
var x = 5;
function f(y) { return (x + y) - 2 };
function g(h) { var x = 7; return h(x) };
{ var x = 10; z = g(f) };
z value is 15. why? the expression (x+y)-2 is being evaluated as (10+7)-2. why does x get the value of 10, and not the value of the previous block, where x = 7? thanks for the help