Question

const d = 4 let a = 1 if (true) { let a = 4 var...

const d = 4
let a = 1
if (true) { 
  let a = 4
  var b = 2
  if (a < 5) {
    var c = 1
    b = 5
  }
}
console.log(a + b + c);

What is is the output and why?

a) The output is 7 because a, b and d are globally scoped variables

b) The output is 7 because b and c are globally scoped variables

Homework Answers

Answer #1

The variable declared outside

of a function becomes GLOBAL.


The global variable has global scope: all scripts

and functions on the web page can be accessed.

for example, in the given code

const d = 4
let a = 1
if (true) { 
  let a = 4
  var b = 2
  if (a < 5) {
    var c = 1
    b = 5
  }
}
console.log(a + b + c);

The output is 7 because b and c are globally scoped variables.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
1. Let T = {(1, 2), (1, 3), (2, 5), (3, 6), (4, 7)}. T :...
1. Let T = {(1, 2), (1, 3), (2, 5), (3, 6), (4, 7)}. T : X -> Y. X = {1, 2, 3, 4}, Y = {1, 2, 3, 4, 5, 6, 7} a) Explain why T is or is not a function. b) What is the domain of T? c) What is the range of T? d) Explain why T is or is not one-to one?
1) Suppose that X and Y are two random variables, which may be dependent and Var(X)=Var(Y)....
1) Suppose that X and Y are two random variables, which may be dependent and Var(X)=Var(Y). Assume that 0<Var(X+Y)<∞ and 0<Var(X-Y)<∞. Which of the following statements are NOT true? (There may be more than one correct answer) a. E(XY) = E(X)E(Y) b. E(X/Y) = E(X)/E(Y) c. (X+Y) and (X-Y) are correlated d. (X+Y) and (X-Y) are not correlated. 2) S.D(X ± Y) is equal to, where S.D means standard deviation a. S.D(X) ± S.D(Y) b. Var(X) ± Var(Y) c. Square...
Let X and Y be jointly distributed random variables with means, E(X) = 1, E(Y) =...
Let X and Y be jointly distributed random variables with means, E(X) = 1, E(Y) = 0, variances, Var(X) = 4, Var(Y ) = 5, and covariance, Cov(X, Y ) = 2. Let U = 3X-Y +2 and W = 2X + Y . Obtain the following expectations: A.) Var(U): B.) Var(W): C. Cov(U,W): ans should be 29, 29, 21 but I need help showing how to solve.
Let X be a binomial random variable with E(X) = 7 and Var(X) = 2.1. (a)...
Let X be a binomial random variable with E(X) = 7 and Var(X) = 2.1. (a) [5 pts] Find the parameters n and p for the binomial distribution. n = p = (b) [5 pts] Find P(X = 4). (Round your answer to four decimal places.) (c) [5 pts] Find P(X > 12)
5. Let X1, X2, . . . be independent random variables all with mean E(Xi) =...
5. Let X1, X2, . . . be independent random variables all with mean E(Xi) = 7 and variance Var(Xi) = 9. Set Yn = X1 + X2 + · · · + Xn n (n = 1, 2, 3, . . .) (a) Find E(Y2) and E(Y5). (b) Find Cov(Y2, Y5). (c) Find E (Y2 | X1). (d) How should your answers from parts (a)–(c) be modified if the numbers “2”, “5”, “7” and “9” are replaced by m,...
1. Let D={0,1,2,3,4,5,6,7,8,9} be the set of digits. Let P(D) be the power set of D,...
1. Let D={0,1,2,3,4,5,6,7,8,9} be the set of digits. Let P(D) be the power set of D, i.e. the set of all subsets of D.    a) How many elements are there in P(D)? Prove it!    b) Which number is greater: the number of different subsets of D which contain the digit 7 or the number of different subsets of D which do not contain the digit 7? Explain why!    c) Which number is greater: the number of different...
true or false: a)Var(X)=E(X^2)-E(X)^2) is always true b)if A and B are dependent then P(A interesection...
true or false: a)Var(X)=E(X^2)-E(X)^2) is always true b)if A and B are dependent then P(A interesection B) - P(A)P(B)=1 c)one of the desavantages of the average is it small sensibility at data change d) Pearson coefficient does not indicate the assimetria of a empiric distribution
True or false; for each of the statements below, state whether they are true or false....
True or false; for each of the statements below, state whether they are true or false. If false, give an explanation or example that illustrates why it's false. (a) The matrix A = [1 0] is not invertible.                               [1 -2] (b) Let B be a matrix. The rowspaces row (B), row (REF(B)) and row (RREF(B)) are all equivalent. (c) Let C be a 5 x 7 matrix with nullity 3. The rank of C is 2. (d) Let D...
6. (6%) Consider this question related to Q3, Q4, and Q5 . Is this statement true:...
6. (6%) Consider this question related to Q3, Q4, and Q5 . Is this statement true: there exist two independent random variables X and Y such that Var [X] = Var [Y] = 1;E[X] = E[Y] = 0, and also Cov [X, Y] = 0? If true, find such example, otherwise prove why this is impossible. 7. (9%) Is it possible that Covariance [X, Y] equals to (a) 0.5 (6%) (b) 5 (3%) or some random variables X and Y....
Let ? = 〈?, ?|? 4 = ? 6 = ?, ?? = ??〉. Let ?:...
Let ? = 〈?, ?|? 4 = ? 6 = ?, ?? = ??〉. Let ?: ℤ4 × ℤ6 → ? by ?(c,d) = ? c? d for all c ∈ {0,1,2,3} and d∈ {0, 1, 2, 3, 4, 5}. prove that ? is a homomorphism and if ? is an isomorphism
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT