Question:
Which value does x have after execution of the following code?
let x = 'Laurel';
let y = 'Hardy';
let z = y;
y = x;
x = z;
Answer:
'Hardy'
x = Laurel
y = Hardy
z = Hardy
y = Laurel
Therefore x = z = Hardy
Declaring and Reassigning Variables can be solves if questions are broken down and simplified.
No comments:
Post a Comment