All right guys, in the next lesson, I've got a coding exercise for you, and it's meant to test 1
your understanding of JavaScript variables. 2
Now, when you head over to the next lesson, you'll find a section with the instructions at the top 3
and your code file at the bottom. 4
Now, the goal is to switch the values that are held in two variables around. 5
So to begin, we have a variable a which holds the value 3 and the variable b which holds the 6
value 8. 7
Now you have to write some code on lines 7, 8 and 9 so that the values are switched around, 8
so that a holds 8 instead and b holds 3. 9
The way I like to think about it is let's say you had two buckets, right? Bucket a and bucket b. A 10
holds some sand and B holds some water. 11
How would you get the contents of these two buckets to switch around? 12
That's basically your goal for this challenge. 13
But there's a couple of rules that you have to follow in order to get the correct answer. 14
Now, first, you should not change any of the existing code. 15
So don't touch this part and don't touch this part. 16
You are just allowed to write in these three lines. 17
Now, the second rule is you're not allowed to type any numbers. 18
You can't just simply say, well, a = 8 and b = 3. 19
This is not a valid solution. 20
Now, the final rule is you're not allowed to redeclare the variables either. 21
So you can't, for example, just say, well, now a= "8" and b = "3". 22
This is also wrong. 23
So have a think about how you can solve this challenge given all of these constraints. 24
And over here, I've got a code playground's set up for you. 25
So when you click on it, you should be taken to the same file where you can write your code and you 26
can use this playground to test out your code. 27
So, for example, at the moment, if I just click run, then it's going to log that a is 3 and 28
b is 8. 29
Now, what we want to happen is when we hit run, it should say the opposite. 30
a is 8 and b is 3. 31
So have a play around with the code and use the Repl.it to test out your code and your hypotheses and 32
hit run to see if it actually does what you expect it to. 33
And then once you think you've got the solution, then go ahead and write them in your code file here 34
and you can click on Check Solution to see if you got the answer right. Now 35
once you're done, you can click, continue and I'll talk you through the solution code. 36
So head over to the next lesson and start the code challenge.