'a' and 'b' could contain anything, so we can't just assign a = 2, b = 1. Also in your answer, you have declared the variable name 'myNumber' twice. I don't think that is permitted in that context.
Here's the solution:
var a = 1;
var b = 2;
// swap 'a' and 'b'var temp = a; // contains 1
a = b; // contains 2
b = temp; // contains 1
I see... It's above my pay-grade, haha! Tomorrow I will pick up a book JavaScript for Kids I ordered from Amazon. Do you prefer to study from books or from online sources?
'a' and 'b' could contain anything, so we can't just assign a = 2, b = 1. Also in your answer, you have declared the variable name 'myNumber' twice. I don't think that is permitted in that context.
Here's the solution:
var a = 1; var b = 2; // swap 'a' and 'b' var temp = a; // contains 1 a = b; // contains 2 b = temp; // contains 1
Does that make sense?
I see... It's above my pay-grade, haha! Tomorrow I will pick up a book JavaScript for Kids I ordered from Amazon. Do you prefer to study from books or from online sources?
I study by driving head on into the problem!
Posted using Partiko iOS
Does it hurt? Haha!
Posted using Partiko Android