See More

--- title: "Exercise: JS Introduction and Variables" slug: "/js-introduction-and-variables-exercise" --- ## 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. 1. Declare a variable named `firstName` using the `const` keyword 2. Declare a variable named `lastName` using the `let` keyword, and assign your name as the **string** value 3. Declare a variable named `age` using the `var` keyword, and assign your age as the **number** value ## Exercise 2: Assigning Values to Variables Steps are to be completed in the `app.js` file. 1. Assign your first name as the **string** value to the variable `firstName` 2. Assign your last name as the **string** value to the variable `lastName` 3. 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. 1. Declare a variable named `language` using the `let` keyword, and assign it the value `"JavaScript"` (string) 2. Declare a variable named `createdYear` using the `let` keyword, and assign it the value `1995` (number) 3. Declare a variable named `isCaseSensitive` using the `let` keyword, and assign it the value `true` (boolean) ## Exercise 4: Declaring and Assigning Values to Variables x2 Steps are to be completed in the `app.js` file. 1. Declare a variable named `price` using the `let` keyword, and assign it the value `19.99` (number) 2. Declare a variable named `isOnSale` using the `let` keyword, and assign it the value `false` (boolean) 3. Declare a variable named `salePercentage` using the `let` keyword, and assign it the value `15` (number) 4. Declare a variable named `stock` using the `let` keyword, and assign it the value `0` (number) 5. Declare a variable named `inStock` using the `let` keyword, and assign it the value `false` (boolean) 6. Declare a variable named `selectedSize` using the `let` keyword, 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. 1. Declare a variable named `title` using the `let` keyword, and assign it the value `"Name of the Wind"` (string) 2. Declare a variable named `author` using the `let` keyword, and assign it the value `"Patrick Rothfuss"` (string) 3. Declare a variable named `pageCount` using the `let` keyword, and assign it the value `722` (number) 4. Declare a variable named `bookmark` using the `let` keyword, and assign it the value `456` (number) 5. Declare a variable named `hasRead` using the `let` keyword, and assign it the value `true` (boolean)