- Fork this repo and
git clone
it down to your computer. - Create two files
index.html
andscript.js
. - Include
script.js
inindex.html
using a<script>
tag. - Open
index.html
in your web browser and open the console. - After answering each section below,
git commit
your work. - When you're finished or when time is up, push your work to your remote repo and file a Pull Request.
Why pay a fortune teller when you can just program your fortune yourself?
Store the following into variables
- job title
- geographic location
- favourite sport
- side project
Using the variables you defined, output your fortune to the console like so:
"You will be a Programmer in Portugal, playing Tennis while building a Flying Car."
Google the formula for converting from Celsius to Fahrenheit and vice versa.
Store a celsius temperature into a variable. Convert it to fahrenheit and output:
"__°C is __°F".
Now store a fahrenheit temperature into a variable. Convert it to celsius and output:
"__°F is __°C".
- Create a variable that contains your birth year.
- Create a variable that contains an arbitrary, future year.
- Calculate your 2 possible ages for that year based on the stored values.
- For example, if you were born in 1996, then in 2022 you'll be either 25 or 26, depending on the month.
- Output to the screen, substituting the correct values like so:
"I will be either __ or __ in YYYY".
For each expression, predict what you think the output will be in a comment (//
) without first running the command. Then run the expression in the console. Note the actual output in a comment and compare it with your prediction.
typeof "potato"
// Prediction: Vegetable
// Actual: String
What is the output of each of the expressions below?
typeof 15
// Prediction:
// Actual:
typeof 5.5
// Prediction:
// Actual:
typeof NaN
// Prediction:
// Actual:
typeof "hello"
// Prediction:
// Actual:
typeof true
// Prediction:
// Actual:
typeof 1 != 2
// Prediction:
// Actual:
console.log("hamburger" + "s")
// Prediction:
// Actual:
console.log("hamburgers" - "s")
// Prediction:
// Actual:
console.log("1" + "3")
// Prediction:
// Actual:
console.log("1" - "3")
// Prediction:
// Actual:
console.log("johnny" + 5)
// Prediction:
// Actual:
console.log("johnny" - 5)
// Prediction:
// Actual:
console.log(99 * "luftbaloons")
// Prediction:
// Actual:
console.log(5 + true)
// Prediction:
// Actual:
console.log(5 + false)
// Prediction:
// Actual:
What's going on in the second half of the previous question ("hamburgers" - "s"
onwards)? Are there any "rules" we can pull from those examples? Further reading.