What is a variable in programming?
A variable is a bucket we can store data in and a way we can tell our program to remember values for us to use later on.
What are the two main things variables allow us to do?
Variables allow us to reuse a value and change a value throughout our program.
In variable declaration, what is let age = 25 doing?
let is the declaration (creating a space in memory), age is the assignment (putting stuff in the bucket), and 25 is the argument (the actual value being stored).
What types of data can you store in variables?
You can store strings (text surrounded by quotes), numbers (integers and floats like 4.16), and booleans (true/false values).
What is camelCase naming convention?
camelCase is a naming convention where the first word is lowercase and subsequent words start with uppercase, like numberOfApples or currentTime.
What are the three primitive data types?
Numbers (for calculations and counting), Strings (any sequence of characters including letters, spaces, numbers, or symbols), and Boolean values (representing true/false logical ideas).
What can you do with the String data type?
Strings can display data that uses text or symbols, add/remove text, and modify characters.
What is the purpose of Boolean values in programming?
Booleans represent logical ideas of true/false. We use them to determine validity and to make decisions in our programs.
What does the Number data type allow us to do?
Numbers allow us to describe, calculate, and count values in our programs.
What are operators in programming?
Operators are different symbols that represent an operation, such as +, -, *, /.
What are the three main categories of operators?
Arithmetic operators (for making calculations), comparison operators (for comparing information), and logical operators (for creating logical expressions).
What are the three logical operators?
AND, OR, and NOT operators, which are used to create logical expressions using boolean values.
What is the purpose of conditional statements?
Conditionals enable us to make decisions and do something if a statement is true. They are either true or false.
What is the basic syntax of an if statement?
if (condition is true) { // Do cool stuff } else if (condition is true) { // Do this other stuff } else { // Other stuff }
What are comparison operators and what do they return?
Comparison operators (==, ===, !=, !==, >, <, >=, <=) compare values and always return either TRUE or FALSE.
What’s the difference between == and ===?
ERROR!
How do you use the AND logical operator (&&)?
AND requires both conditions to be true. Example: if (name === “Leon” && status === “Baller”) { // Do something }
How do you use the OR logical operator (||)?
OR requires at least one condition to be true. Example: if (day === “Saturday” || day === “Sunday”) { // It’s the weekend }
What is an important rule about assignment (=) vs comparison (==, ===)?
Single equal sign (=) will always be reassignment, while 2-3 equal signs (==, ===) will always be comparison.
What is a function?
A function is a simple set of instructions or a named sequence of instructions, packaged as a unit, that performs a specific task.
Why are functions important in programming?
Functions form the basic “building blocks” of a program, make code reusable, and allow us to put a set of instructions into memory so we can use it over and over again.
What are the two parts of using a function?
Function declaration (when we define a function and specify the instructions, inputs, and name) and function call (when we tell the function to run and execute all its instructions).
What is the difference between parameters and arguments?
Parameters are the inputs specified when we define a function. Arguments are the actual values we give for each input when we call the function.
When does a function actually run?
A function won’t run unless it’s called. You write it once but can reuse it over and over again by passing in different arguments.