Skip to content
This repository was archived by the owner on Jan 14, 2024. It is now read-only.

Commit 9434d5b

Browse files
authored
Merge pull request #164 from moneyinthesky/main
Using let instead of var, Adding info on testing
2 parents 0f9d4c8 + fc196a2 commit 9434d5b

File tree

20 files changed

+62
-56
lines changed

20 files changed

+62
-56
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ https://github.com/CodeYourFuture/JavaScript-Core-1-Coursework-Week2-Solution
1212

1313
This is a **private** repository. Please request access from your Teachers, Buddy or City Coordinator after the start of your next lesson.
1414

15+
## Testing your work
16+
17+
- Each of the *.js files in the `exercises` folder can be run from the terminal using the `node` command with the path to the file. For example, `node exercises/B-boolean-literals/exercise.js` can be run from the root of the project.
18+
- To run the tests in the `mandatory` folder, run `npm run test` from the root of the project (after having run `npm install` once before).
19+
- To run the tests in the `extra` folder, run `npm run extra-tests` from the root of the project (after having run `npm install` once before).
20+
1521
## Instructions for submission
1622

1723
For your homework, we'll be using [**test driven development**](https://medium.com/@adityaalifnugraha/test-driven-development-tdd-in-a-nutshell-b9e05dfe8adb) to check your answers. Test driven development (or TDD) is the practice of writing tests for your code first, and then write your code to pass those tests. This is a very useful way of writing good quality code and is used in a lot of industries. You don't have to worry about knowing how this works, but if you're curious, engage with a volunteer to find out more! :)

exercises/A-expressions/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ We can take the value produced by an expression and assign it to a variable. Tha
2020
A statement is some code that performs an action. Here are some examples:
2121

2222
```js
23-
var sum = 1 + 1; // action: assigns result of `1 + 1` to variable `sum`
24-
var greeting = "hello"; // action: assigns result of the expression "hello" to variable `greeting`
23+
let sum = 1 + 1; // action: assigns result of `1 + 1` to variable `sum`
24+
let greeting = "hello"; // action: assigns result of the expression "hello" to variable `greeting`
2525
console.log(2 * 4); // action: logs the result of `2 * 4` to the console
2626
sayGreeting(greeting); // action: calls the function `sayGreeting` with the parameter `greeting`
2727
```
@@ -46,7 +46,7 @@ $ node
4646
3
4747
> "hello"
4848
'hello'
49-
> var greeting = "hello"
49+
> let greeting = "hello"
5050
undefined
5151
> greeting
5252
'hello'

exercises/B-boolean-literals/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
There is a special data type in JavaScript known as a **boolean** value. A boolean is either `true` or `false`, and it should be written without quotes.
22

33
```js
4-
var codeYourFutureIsGreat = true;
4+
let codeYourFutureIsGreat = true;
55
```
66

77
## Exercise

exercises/B-boolean-literals/exercise.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Add the required variables with the correct boolean values assigned.
66
*/
77

8-
var codeYourFutureIsGreat = true;
8+
let codeYourFutureIsGreat = true;
99

1010
/*
1111
DO NOT EDIT BELOW THIS LINE

exercises/C-comparison-operators/exercise.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
The variables should have values that match the expected results.
66
*/
77

8-
var studentCount = 16;
9-
var mentorCount = 9;
10-
var moreStudentsThanMentors; // finish this statement
8+
let studentCount = 16;
9+
let mentorCount = 9;
10+
let moreStudentsThanMentors; // finish this statement
1111

12-
var roomMaxCapacity = 25;
13-
var enoughSpaceInRoom; // finish this statement
12+
let roomMaxCapacity = 25;
13+
let enoughSpaceInRoom; // finish this statement
1414

15-
var personA = "Daniel";
16-
var personB = "Irina";
17-
var sameName; // finish this statement
15+
let personA = "Daniel";
16+
let personB = "Irina";
17+
let sameName; // finish this statement
1818

1919
/*
2020
DO NOT EDIT BELOW THIS LINE

exercises/D-logical-operators/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ They let you write expressions that evaluate to a boolean value.
55
Suppose you want to test if a number if bigger than 3 and smaller than 10. We can write this using logical operators.
66

77
```js
8-
var num = 10;
8+
let num = 10;
99

1010
function satisfiesRequirements(num) {
1111
if (num > 3 && num < 10) {
@@ -20,7 +20,7 @@ We can test expressions with logical operators in a node console too:
2020

2121
```sh
2222
$ node
23-
> var num = 10;
23+
> let num = 10;
2424
undefined
2525
> num > 5 && num < 15
2626
true
@@ -30,7 +30,7 @@ true
3030
true
3131
> !true
3232
false
33-
> var greaterThan5 = num > 5
33+
> let greaterThan5 = num > 5
3434
undefined
3535
> !greaterThan5
3636
false

exercises/D-logical-operators/exercise.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@
66
*/
77

88
// Do not change these two statement
9-
var htmlLevel = 8;
10-
var cssLevel = 4;
9+
let htmlLevel = 8;
10+
let cssLevel = 4;
1111

1212
// Finish the statement to check whether HTML, CSS knowledge are above 5
1313
// (hint: use the comparison operator from before)
14-
var htmlLevelAbove5;
15-
var cssLevelAbove5;
14+
let htmlLevelAbove5;
15+
let cssLevelAbove5;
1616

1717
// Finish the next two statement
1818
// Use the previous variables and logical operators
1919
// Do not "hardcode" the answers
20-
var cssAndHtmlAbove5;
21-
var cssOrHtmlAbove5;
20+
let cssAndHtmlAbove5;
21+
let cssOrHtmlAbove5;
2222

2323
/*
2424
DO NOT EDIT BELOW THIS LINE

exercises/E-conditionals/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The most common type of conditional is the **if statement**.
1010
An if statment runs some code if a condition is met. If the condition is not met, then the code will skipped.
1111

1212
```js
13-
var isHappy = true;
13+
let isHappy = true;
1414

1515
if (isHappy) {
1616
console.log("I am happy");
@@ -51,7 +51,7 @@ An if statement runs code when a condition is met. What if the condition is not
5151
An **if...else statement** also runs code when the condition is _not_ met.
5252

5353
```js
54-
var isHappy = true;
54+
let isHappy = true;
5555

5656
if (isHappy) {
5757
console.log("I am happy 😄");

exercises/E-conditionals/exercise.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
If Daniel is a student, print out "Hi, I'm Daniel, I'm a student."
77
*/
88

9-
var name = "Daniel";
10-
var danielsRole = "mentor";
9+
let name = "Daniel";
10+
let danielsRole = "mentor";
1111

1212
/*
1313
EXPECTED RESULT

exercises/G-conditionals-2/exercise-1.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ function negativeOrPositive(number) {}
1111
/*
1212
DO NOT EDIT BELOW THIS LINE
1313
--------------------------- */
14-
var number1 = 5;
15-
var number2 = -1;
16-
var number3 = 0;
14+
let number1 = 5;
15+
let number2 = -1;
16+
let number3 = 0;
1717

1818
console.log(number1 + " is " + negativeOrPositive(number1));
1919
console.log(number2 + " is " + negativeOrPositive(number2));

0 commit comments

Comments
 (0)