forked from softwareEngineeringCurriculm/Javascript-Part-I
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f08fba4
commit 0209665
Showing
1 changed file
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
# Part II: Foundations of Programming | ||
|
||
*Note: Before getting started on these exercises, please be certain that you've read through the root [README.md](../README.md) file in this repository.* | ||
|
||
## Exercises | ||
|
||
### Basic Requirements | ||
|
||
#### Numbers | ||
|
||
1. Enter the following expressions into your console. | ||
|
||
```js | ||
1 + 2 | ||
3 * 5 | ||
5 / 4 - 13 | ||
5000 * 234 | ||
1073 / 57 + 200 | ||
``` | ||
|
||
2. Why are the values produced by the following two expressions different? What | ||
are they? | ||
|
||
```js | ||
3 + 2 * 4 - 1 | ||
(3 + 2) * (4 - 1) | ||
``` | ||
|
||
3. Calculate 50 years in minutes using the console. | ||
|
||
4. What is the percentage of letters in the english alphabet that are vowels (including y)? Use the | ||
console to find out. | ||
|
||
5. Try the following expressions in the console: | ||
|
||
```js | ||
6 % 2 | ||
42 % 10 | ||
5 % 2 | ||
6 % 3 | ||
7 % 4 | ||
100 % 12 | ||
``` | ||
|
||
What is the significance of the result? How does the `%` (modulus) operator | ||
work? | ||
|
||
6. Try the following: | ||
|
||
```js | ||
3 % 2 | ||
4 % 2 | ||
5 % 2 | ||
6 % 2 | ||
``` | ||
|
||
What do the results tell you about the first operand to the modulus operator? | ||
|
||
#### Strings | ||
|
||
1. Write a string that represents your full name. | ||
|
||
2. Write a string that represents your favorite food. | ||
|
||
3. Use the `+` operator to combine (known as *concatenation*) two or more | ||
strings, *e.g.*: | ||
|
||
```js | ||
// Your first and last names | ||
"John" + " " + "Doe" | ||
``` | ||
|
||
+ Your first and last names (as shown above) | ||
+ Your best friend's full name | ||
+ Your home town, state and country | ||
4. Fix the errors in the following strings: | ||
```js | ||
Where are all the quotes? | ||
'hmm something is not right" | ||
'Do other ' * 'operators work with string concatenation? | ||
``` | ||