Skip to content

Commit a65368d

Browse files
authored
Foundations of Programming
1 parent f68f822 commit a65368d

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed

foundations.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Foundations of Programming
2+
3+
## Objectives
4+
5+
- Understand what a program is
6+
- Understand why JavaScript is a useful programming language for beginners to learn
7+
- Describe and use JavaScript _expressions_
8+
- Describe and use arithmetic _operators_
9+
- Describe and use `number` and `string` data _types_
10+
11+
## Lecture Slides
12+
13+
[Slides are here](https://docs.google.com/presentation/d/e/2PACX-1vSMm-b3hSJwjgc4TQe7YnXfVjpdgklt4Ma30sfWULU4jDxt0XplMXLX0vMem6cVBj8LDlbhtLSNpb4s/embed?start=false&loop=false&delayms=10000)
14+
15+
## Exercises
16+
17+
### Basic Requirements
18+
19+
You will only need your Chrome browser with the developer console open for the following activities.
20+
21+
#### Vocabulary
22+
23+
Can you try to define the following in your own words?
24+
25+
- _expression_
26+
- _operator_
27+
- _type_
28+
29+
#### `number`s & `string`s
30+
31+
##### `number`s
32+
33+
1. Enter the below expressions, line by line, into your Chrome console. What happens for each?
34+
35+
```js
36+
4 + 10;
37+
1 * 3;
38+
12 * 4;
39+
4 % 2;
40+
5 % 2;
41+
5 / 1 - 99;
42+
5000 * -100 * (1 + 2) * (5 * 6);
43+
1241 / 9 + 99;
44+
```
45+
46+
1. Based on your work above, what does `%` do?
47+
48+
1. Calculate your age in minutes using the console.
49+
50+
##### Bonus Section
51+
52+
1. The console is getting a little full. Use `clear()` to clean things up a little.
53+
54+
##### `string`s
55+
56+
1. In your console, put your name in a `string`!
57+
58+
1. Use the `+` operator to _concatenate_ (join together) two or more
59+
`string`s, _e.g._:
60+
61+
```js
62+
// Your first and last names as an example
63+
"Yan " + "Fan";
64+
```
65+
66+
- Your first and last names (as shown above in the example code snippet)
67+
- Your favourite singer's full name
68+
- Code Chrysalis
69+
70+
1. Try the following in your console, line by line. What happens? Fix the errors:
71+
72+
```js
73+
Where are the quotes?
74+
'hmm something is not right"
75+
'Do other ' * 'operators work with string concatenation?
76+
```
77+
78+
1. We want you to get comfortable with actively exploring through code. Answer the following questions by coding to test the questions:
79+
1. What happens when I add a `string` and a `number` together?
80+
1. What if I reverse the order (e.g. `number` + `string`)?
81+
1. What happens if I multiply a `number` 5 with a `string` "5"?
82+

0 commit comments

Comments
 (0)