We can compare variables with buckets or boxes that can contain data
values. Variables are containers that can store data. We can declare a
variable and then initialize it by assigning it with a data value.
Instructions
Now that we have learned about variables if you want to read more
about it, I suggest you go to your favorite search engine and then search the term
JavaScript variables.
Select one of the results and READ more about the different things
about variables.
Now that you have practice doing some RESEARCH about
what a variable is in Javascript. Let's go and try to solve this challenge.
If your stuck, don't be afraid to ASK questions and get help from the community.
Follow the steps to accomplish this exercise.
Open Firefox.
Press on F12 to open the developer tools.
Go to the console tab inside of the developer tools of Firefox
(The developer tools is going to be
your bestfriend for bug hunting).
Type in the console the following:
function bucketTest( ){
console.log('bucket1 is ' + bucket1);
console.log('bucket2 is ' + bucket2);
}
bucketTest();
Inside of the function declare a variable name bucket1 and initialize a value for it by
assigning a value of 10.
Inside of the function declare a variable name bucket2 and initialize a value for it by
assigning a value of 20.
Now you would see the Run button on the upper left corner try to press that to see the results.
Now our goal is to run a function that will switch the values of bucket1 and bucket2.