# variables Variables are used to store data. Each variable has a name and holds a value. Think of it like a box: slap on a label, and it can store stuff. šŸ“¦ The variable name can consist of letters, numbers, and the _ underscore, but cannot start with a number. These are all valid variable names and values: ```javascript var name = 'Joe' var name2 = 'Joseph' var userId = 26789437849 var progress = 0.75 var xp = 60 var verified = true ``` Depending on how you create a variable, we can also change the value of a variable or print it out: ```javascript let xp = 70 xp = 80 console.log(xp) // Output: 80 var xp = 70 xp = 80 console.log(xp) // Output: 80 const xp = 70 xp = 80 // Error ``` Here, we are assigning the number value 70 to the variable xp. Then, we are reassigning the number value 80 to the same variable. And printing it out. # data types ## Number In Javascript, a Number can either be a whole number, or a decimal. ```javascript var year = 2025 var age = 32.489 ``` ## string A string, or str, is used for storing text. Strings are wrapped in double quotes " ", single quotes ' ', or backticks \`\`. ```javascript var email = "[email protected]" var username = '@snoopdogg' var message = `good nite` ``` ## boolean A Boolean data type, or bool, stores a value that can only be either true or false. ```javascript var lateToClass = false var cranky = true ``` # operators `x + y` | Sum of two numbers `x - y` | Difference of two numbers `x * y` | Product of two numbers `x / y` | Quotient of two numbers `x % y` | x "modulo" y: The remainder of x / y for positive x, y `x ** y` | x raised to the power y `-x` | A negated number `x == y` | Check if x is similar to y (ex, `0` is similar to `false`) `x === y` | Check if x is identical to y (ex, `0` is not identical to `false`) `x != y` | Check if two values are dissimilar `x !== y` | Check if two values are different `x > y` | Check if x is greater than y `x >= y` | Check if x is greater than or equal to y `x < y` | Check if x is less than y `x <= y` | Check if x is less than or equal to y `x++` | increase x by 1 `x--` | decrease x by 1 `x += y` | increase x by y `x -= y` | decrease x by y ## using operators Operators can be used to alter numbers (and sometimes strings). ```javascript console.log(2 + 3) // Output: 5 ``` ```javascript console.log("Hello " + "World") // Output: Hello World ``` ## operators with variables Operators can also be used with variables. That can help you keep track of what you're doing. ```javascript var pizza = 2.99 var coke = 0.99 var total = pizza + coke var tip = total * 0.2 console.log(tip) // Output: 0.796 ``` # instructions Complete each of the following challenges using variables, operators, and `console.log()`. **Challenge 1** > Create a program that determines the sales tax for a given price. It should `console.log()` the sales tax and the total including the tax. **Challenge 2** > Create a program that determines the tip you should give at a restaurant. It should start with the total (dollar amount), calculate taxes and a 20% tip, and `console.log()` the original total, tax, tip, and grand total. **Challenge 3** > Create a program that converts a number from Fahrenheit (F) to Celsius (C). > > $ > C = \frac{5}{9} \cdot (F - 32) > $ > > `console.log()` the result.