Exercise: Juggling Values
Explore how to swap values among three variables using JavaScript's variable mutation concepts. This exercise strengthens your understanding of variables and prepares you for challenges in handling value assignments effectively.
We'll cover the following...
Task
Due to unforeseen circumstances, some values of variables have been shifted into one another. Your task: to fix this using your newly acquired knowledge of variable mutation.
Problem statement
You are given three variables named var1, var2 and var3. Write code such that the following is satisfied:
var1contains the value ofvar2var2contains the value ofvar3var3contains the value ofvar1
The above diagram illustrates this perfectly. Keeping the above problem in mind, complete the following code. Whenever you feel that you have done it, hit TEST. Good luck!
Code now
NOTE: You can always call in
console.log()for debugging purposes. All the print statements fromconsole.log()are in the “Show Console” tab after hitting TEST.