Exercise: JS Introduction and Variables
Objective#
Your objective is to begin using variables to store and pass values throughout your program.
To see your work, you can log, or print, the values stored in your variables to the console. Use
console.log(variableName)to see your results in the browser console.
Exercise 1: Declaring Variables#
Steps are to be completed in the app.js file.
- Declare a variable named
firstNameusing theconstkeyword - Declare a variable named
lastNameusing theletkeyword, and assign your name as the string value - Declare a variable named
ageusing thevarkeyword, and assign your age as the number value
Exercise 2: Assigning Values to Variables#
Steps are to be completed in the app.js file.
- Assign your first name as the string value to the variable
firstName - Assign your last name as the string value to the variable
lastName - Assign your age as the number value to the variable
age
Exercise 3: Declaring and Assigning Values to Variables#
Steps are to be completed in the app.js file.
- Declare a variable named
languageusing theletkeyword, and assign it the value"JavaScript"(string) - Declare a variable named
createdYearusing theletkeyword, and assign it the value1995(number) - Declare a variable named
isCaseSensitiveusing theletkeyword, and assign it the valuetrue(boolean)
Exercise 4: Declaring and Assigning Values to Variables x2#
Steps are to be completed in the app.js file.
- Declare a variable named
priceusing theletkeyword, and assign it the value19.99(number) - Declare a variable named
isOnSaleusing theletkeyword, and assign it the valuefalse(boolean) - Declare a variable named
salePercentageusing theletkeyword, and assign it the value15(number) - Declare a variable named
stockusing theletkeyword, and assign it the value0(number) - Declare a variable named
inStockusing theletkeyword, and assign it the valuefalse(boolean) - Declare a variable named
selectedSizeusing theletkeyword, and assign it the value"M"(string)
Exercise 5: Declaring and Assigning Values to Variables x3#
Steps are to be completed in the app.js file.
- Declare a variable named
titleusing theletkeyword, and assign it the value"Name of the Wind"(string) - Declare a variable named
authorusing theletkeyword, and assign it the value"Patrick Rothfuss"(string) - Declare a variable named
pageCountusing theletkeyword, and assign it the value722(number) - Declare a variable named
bookmarkusing theletkeyword, and assign it the value456(number) - Declare a variable named
hasReadusing theletkeyword, and assign it the valuetrue(boolean)