Learn to Make a Website
with CodeCademy
Lesson 18: Calculations with JS
Instruction Overview
Understand
- How to apply arithmetic to JS variables and how to generate pseudorandom numbers
- Have an elementary understanding of properties and methods, and know one use case for each
Apply
- Complete CodeCademy exercises 2.5-2.10
- Use arithmetic, concatenation, .length, and .toUpperCase in classroom quiz show
Create
- Have students generate a quiz for their classmate
For the instructor's eyes only
Today will be filled with challenges
Sometimes the best way to learn is by solving specific problems
Class goals
☐ Complete CodeCademy JS exercises 2.5-2.8
☐ Develop a quiz for your classmates in CodePen
Let's log onto CodeCademy
Head over to www.codecademy.com
Click Log In
Once logged in, click Catalog
Find Introduction to JavaScript and start course
Task
☐ Complete 2.5 (Arithmetic Operators) to 2.6 (String Concatenation)
☐ Open a new CodePen pen (make sure console is open)
10 min
Challenge #1
30
Points
Difficulty
Console.log the following 3 calculations:
1. How many days are there in 6 years?
2. If there was $1000 divided among a class of 16 students, how much money would each student get?
3. How many years from now is 4013 AD?
SOLUTION
console.log(365*6); //2190 or 2191 with leap year
console.log(1000/16); //$62.50 each
console.log(4013-2019); //1994
Challenge #2
50
Points
Difficulty
1. Create two variables called age and name and set them to your age and name.
2. Console.log a phrase that tells the user your name, age, and how old you'll be in 57 years (using math operators).
SOLUTION
console.log("My name is " + name + " and I am " + age + " years old. In 57 years, I'll be " + (age+57) + " years old.");
const age = 12;
const name = 'Joe';
Task
☐ Complete 2.7 (Properties) to 2.8 (Methods)
10 min
Class goals
☑ Complete CodeCademy JS exercises 2.5-2.8
☐ Develop a quiz for your classmates in CodePen
Challenge #3
80
Points
Difficulty
1. Create a variable called fullName and set it to your full name. Use the .length property to console.log the number of letters in your full name. Check your work!
2. Convert your full name to uppercase and console.log it.
SOLUTION
console.log(fullName.toUpperCase());
const fullName = 'Joe Pesci';
console.log(fullName.length - 1);
Task
☐ Open a new CodePen project called "Quiz Show"
☐ Create a 3-question quiz (similar to the ones we did in class)
☐ Ask a classmate to try the quiz
10 Min
You must know the solutions for your own quiz!
Class goals
☑ Complete CodeCademy JS exercises 2.5-2.8
☑ Develop a quiz for your classmates in CodePen
👏🏿
Next Lesson:
Use magical random numbers!
Make a Website with CodeCademy Lesson 18 - Calculations with JS
By scholarstem
Make a Website with CodeCademy Lesson 18 - Calculations with JS
- 312