In this task, you will using the console inspector to explore variables and Javascript. Please follow the instructions below-if you get stuck, ask!
- In class, you looked at how to access the console of a web browser. Do so now, and make sure it is blank (you may need to open up a blank web page to do this). undefined
- In the console, type
let myName = "<your name>"
and pressEnter
. What response does the console return? ____undefined ________(enter response here) - You've made your first variable! To recall the variable, type
myName
and hitEnter
. Did you get what you expected? - Now change the value of the variable to by typing
myName = <new value>
and hitEnter
. Try to get back the new value. Try changing it to a letter, number,null
or eventrue
orfalse
(what do you call these?). - Restore the variable to its original value. Create another variable with any name you choose. However, instead of using
let
, use the wordconst
. Retrieve the value as before. - With your new variable, try to change the value. What happens? Why might this be important?
- Create a JS file. You can name it as you wish, making sure it ends with
.js
. Place the variables you created there. - Back to the console, create numerical variables and try to add, subtract, multiply and divide them. Take one of the variable and try to divide by 0. Does your website crash?
- Going back to the first variables you created, set the variable of your first variable, to the second variable. To do this, type
myName = <yourSecondVariable>
. Now try to changemyName
-is it possible? Why do you think so?
[X ] I have completed this task
Now complete Task 2.