Exercise: JS Introduction and Variables
#
ObjectiveYour 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 VariablesSteps are to be completed in the app.js
file.
- Declare a variable named
firstName
using theconst
keyword - Declare a variable named
lastName
using thelet
keyword, and assign your name as the string value - Declare a variable named
age
using thevar
keyword, and assign your age as the number value
#
Exercise 2: Assigning Values to VariablesSteps 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 VariablesSteps are to be completed in the app.js
file.
- Declare a variable named
language
using thelet
keyword, and assign it the value"JavaScript"
(string) - Declare a variable named
createdYear
using thelet
keyword, and assign it the value1995
(number) - Declare a variable named
isCaseSensitive
using thelet
keyword, and assign it the valuetrue
(boolean)
#
Exercise 4: Declaring and Assigning Values to Variables x2Steps are to be completed in the app.js
file.
- Declare a variable named
price
using thelet
keyword, and assign it the value19.99
(number) - Declare a variable named
isOnSale
using thelet
keyword, and assign it the valuefalse
(boolean) - Declare a variable named
salePercentage
using thelet
keyword, and assign it the value15
(number) - Declare a variable named
stock
using thelet
keyword, and assign it the value0
(number) - Declare a variable named
inStock
using thelet
keyword, and assign it the valuefalse
(boolean) - Declare a variable named
selectedSize
using thelet
keyword, and assign it the value"M"
(string)
#
Exercise 5: Declaring and Assigning Values to Variables x3Steps are to be completed in the app.js
file.
- Declare a variable named
title
using thelet
keyword, and assign it the value"Name of the Wind"
(string) - Declare a variable named
author
using thelet
keyword, and assign it the value"Patrick Rothfuss"
(string) - Declare a variable named
pageCount
using thelet
keyword, and assign it the value722
(number) - Declare a variable named
bookmark
using thelet
keyword, and assign it the value456
(number) - Declare a variable named
hasRead
using thelet
keyword, and assign it the valuetrue
(boolean)