- Javascript Foundations
- Boolean Logic
- Introduction to the Chrome Developer Tools
Notes: In this lab, we are going to practice fundamental programming skills. As programmers, we will be performing numerous calculations that we want to save. We'll practice using variables to save these values so that we can reuse them later on.
There will also be instances where we won't write our own code from scratch. Instead, we will use code that other people have created and tested heavily. To do this, we'll have to be comfortable reading documentation to learn how to use other people's existing code, as well as how to incorporate it into our own code.
When tackling a new programming challenge, it is tempting to dive right into the code. For simpler problems that the developer has seen before, this might not be an issue. But for larger problems that they haven't seen before, developers will usually plan out their solution in plain English to make sure their logic is correct. We'll practice pseudocode so we can be comfortable tackling new problems that come our way.
- Follow the instructions provided in the
main.js
file in thestarter-code
folder. - Open the
index.html
file and examine the console in the Developer Tools. Look here to see if your code is producing the correct results.
- Create three variables:
name
,age
, andaddress
.- Create a fourth variable,
greeting
, that combines these three variables to form a greeting. - For example, "Hello, I'm Anthony, I'm 20 years old and live at 100 Main St."
- Log this fourth variable to the console. Check the console to make sure you're getting the desired result.
- Create a fourth variable,
- Create another variable called
greeting2
. - This time, use the new ES6 Syntax, string interpolation, to create the same greeting.
- Hint: String interpolation uses
backticks
instead of quotation marks. - Log the
greeting2
variable to the console. Check the console to make sure you're getting the desired result.
- Hint: String interpolation uses
- "Code Testing." Let's check and see if we did everything correctly and that
greeting
returns the same value asgreeting2
. - Create a variable problemSolved whose value is the boolean value of if
greeting
andgreeting2
are equivalent. Log this variable to the console to check the values result. - If the return is false, correct your bugs above until
greeting
andgreeting2
are equivalent.
- We are given a list of 20 numbers. We have to go through the list and find the largest number.
- What would the pseudocode for this problem look like? What variables would we need?
- Hint: How would we solve this problem if we had to do this with pencil and paper?
- What number would we write down in order to remember? Anything that you write down probably belongs in a variable.
- Extra Bonus Question: What would the pseudocode look like if you also had to find the smallest number?