Skip to content
This repository was archived by the owner on Jan 3, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
a3c5a55
Add choose your own adventure game
40thieves Feb 7, 2021
d28e2f6
Merge pull request #28 from CodeYourFuture/update-mandatory-exercises
Feb 12, 2021
e8eeb1c
Make the game interactive, instead of via function calls
40thieves Feb 18, 2021
8a844db
Improve comments
40thieves Feb 18, 2021
8d43cd3
Add some nicer error handling
40thieves Feb 18, 2021
b7b2d5f
Switch to using rooms object instead of separate rooms objects
40thieves Mar 10, 2021
75e7f79
Add spacing between task and hints
illicitonion Feb 21, 2021
85b427d
Lower-case the room names
illicitonion Feb 21, 2021
19b1dbd
Make !game.currentRoom error message more accurate
illicitonion Feb 21, 2021
ead4faa
Add HOW_TO_MARK.md
Mar 12, 2021
e02a83a
Merge remote-tracking branch 'template/main' into main
Mar 12, 2021
7682727
Typo Fix
Mar 12, 2021
edad7f8
Merge remote-tracking branch 'template/main' into main
Mar 12, 2021
3070cdc
Merge pull request #52 from illicitonion/cyoa
40thieves Mar 13, 2021
108b7de
Fix wording
40thieves Mar 13, 2021
f0ccb3f
Merge pull request #27 from CodeYourFuture/add-more-exerises
40thieves Mar 17, 2021
8b9441b
Fix room directions not being functions
40thieves Mar 24, 2021
328ca7a
Improve error checking
40thieves Mar 24, 2021
db523eb
Merge pull request #78 from CodeYourFuture/fix-cyoa
Mar 26, 2021
f6efa1e
Update 9-choose-your-own-adventure.js
Apr 1, 2021
7cdfeae
People I Know test case is order-insensitive
illicitonion Apr 27, 2021
4b9d2d6
Add writers on edge-cases of age range
illicitonion Apr 27, 2021
b900004
Add check that partial-pouring works
illicitonion Apr 27, 2021
99264be
Merge pull request #85 from illicitonion/pour-check
Apr 28, 2021
accfa7f
Merge pull request #84 from illicitonion/writers-ages
Apr 28, 2021
84b8197
Merge pull request #83 from illicitonion/people-order-insensitive
Apr 28, 2021
6f1ec5f
Add tests for groceries exericse (#82)
illicitonion May 9, 2021
7239423
Add JS1 recap exercises (#86)
illicitonion May 9, 2021
f80e04e
Close PRs after six weeks
May 13, 2021
ee11d92
Merge remote-tracking branch 'template/main' into main
May 13, 2021
dc1cd42
Update close.yml
May 13, 2021
f87b11f
Merge remote-tracking branch 'template/main' into main
May 13, 2021
499a26c
Misc fixes (#80)
illicitonion May 23, 2021
69a2c81
Convert tests to jest
gregdyke Jun 23, 2021
bfc4eb9
address review comments (mainly use toIncludeSameMembers)
gregdyke Jun 26, 2021
b9a8fd4
Merge pull request #88 from gregdyke/jestify-js2w1
gregdyke Jun 27, 2021
8304cf2
Jestify 4-waterbottle and 11-choose-your-own-adventure
gregdyke Jul 1, 2021
5b52be2
fix mismatched test descriptions, adapt readme
gregdyke Jul 3, 2021
69bbe56
Fix incorrect logic in CYOA game harness
40thieves Jul 21, 2021
b4a864b
Merge pull request #90 from gregdyke/jestify_js2wk1_b
gregdyke Jul 24, 2021
3725364
Simplify error check with optional chaining operator
40thieves Aug 2, 2021
33ef0ac
Merge pull request #96 from CodeYourFuture/fix-cyoa-harness
40thieves Aug 3, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ For example,

London Class 7 - Chris Owen - HTML/CSS - Week 1

Please complete the details below this message

-->

**Volunteers: Are you marking this coursework?** _You can find a guide on how to mark this coursework in `HOW_TO_MARK.md` in the root of this repository_

# Your Details

- Your Name:
Expand All @@ -20,3 +24,13 @@ London Class 7 - Chris Owen - HTML/CSS - Week 1

- Module:
- Week:

# Notes

- What did you find easy?

- What did you find hard?

- What do you still not understand?

- Any other notes?
17 changes: 17 additions & 0 deletions .github/workflows/close.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: "Close stale issues and PRs"
on:
workflow_dispatch:
schedule:
- cron: "30 1 * * *"

jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v3
with:
stale-pr-message: "Your coursework submission has been closed because nobody has interacted with it in six weeks. You are welcome to re-open it to get more feedback."
days-before-stale: 42
days-before-close: 0
days-before-issue-stale: -1
days-before-issue-close: -1
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/node_modules
/package-lock.json
Empty file added .setup/jest.setup.js
Empty file.
64 changes: 64 additions & 0 deletions HOW_TO_MARK.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<!--
Do not edit this file.
Make a change to the template and then pull changes.
https://github.com/CodeYourFuture/CYF-Coursework-Template
-->

_This file is useful for Volunteers only_

## 1) Solutions

### 1.1) Where to find solutions?

You can find the solution to this coursework in a repository with the same name as this but with `-Solution` after the name.

For example, for this repo:

https://github.com/CodeYourFuture/JavaScript-Core-1-Coursework-Week1

The solutions would be found in:

https://github.com/CodeYourFuture/JavaScript-Core-1-Coursework-Week1-Solution

**If you do not have access to these repositories** then please contact your City Coordinator to get access to our Github Team.

### 1.2) Using the Solutions Repo

In these repositories you will find solutions to each weeks coursework. These solutions are example answers and will not be the exact solution that students give. You should use it to inform your feedback of the coursework.

Additionally, you will find marking guides in these places

- The `marking` folder - Used to store multiple guides on marking
- `marking.md` file - Used to store notes on common problems we're trying to address
- `solutions.md` - A file used by students for notes on best practice

## 2) Before You Start

### 2.1) Feedback Guide

A guide for marking coursework can be found here. Please read it before you start.

https://docs.codeyourfuture.io/teams/education/homework-feedback

### 2.2) Marking Guide

Here is a useful resources you can direct students to when you see them have common mistakes

https://syllabus.codeyourfuture.io/guides/marking-guide

This guide should be used when you see a student making a common mistake so instead of writing out a reply you can send them to the a good resource.

For example, if the student is leaving in lots of comments out code you could write

```txt
Great work so far!

It's best if you remove code that you're not using, you can read more about this here
https://syllabus.codeyourfuture.io/guides/marking-guide#commented-out-code
```

### 3.3) Style Guide

All code at CYF should follow this Style Guide

https://syllabus.codeyourfuture.io/guides/code-style-guide/
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@ The exercises are split into three folders: `exercises`, `mandatory` and `extra`

The `extra` folder contains exercises that you can complete to challenge yourself, but are not required for the following lesson.

## Running the code/tests

These files for the exercises are intended to be run as jest tests.

- Once you have cloned the repository, run `npm install` once in the terminal to install jest (and any necessary dependencies).
- To run all exercises/tests in the mandatory folder, run `npm test`
- To run a single exercise/test (for example `mandatory/1-writer.js`), run `npm test -- --testPathPattern mandatory/1-writer.js` (Remember, you can use tab-completion to get files relative to the current directory, so m`Tab ↹`/1-`Tab ↹` will autocomplete get you the test file starting with 1-)
- Some of the exercises do not use jest. To run these individually, use node directly. `node mandatory/7-recipes.js`. These are:
- `7-recipes.js`

For more information about tests, look here:

https://syllabus.codeyourfuture.io/guides/intro-to-tests

## Solutions

Expand Down
55 changes: 53 additions & 2 deletions mandatory/1-writers.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ let writers = [
firstName: "Zadie",
lastName: "Smith",
occupation: "writer",
age: 41,
age: 40,
alive: true,
},
{
Expand All @@ -46,9 +46,16 @@ let writers = [
firstName: "Bell",
lastName: "Hooks",
occupation: "writer",
age: 64,
age: 63,
alive: true,
},
{
firstName: "Yukiko",
lastName: "Motoya",
occupation: "writer",
age: 49,
alive: true,
}
];

/*
Expand All @@ -59,6 +66,9 @@ Exercise 1:

"Hi, my name is {firstName} {lastName}. I am {age} years old, and work as a {occupation}."
*/
function logAllWriters() {
// write your code to log all writers here
};

/*
Exercise 2:
Expand All @@ -69,10 +79,51 @@ Exercise 2:
"Writer {firstName} {lastName} died at {age} years old."
*/

function logDeadWritersInTheirForties() {
// write your code here
}

/*
Exercise 3:

Only `console.log()` out alive writers who are in their 40s (meaning between 40 and 49):

"Hi, my name is {firstName} {lastName}. I am {age} years old."
*/

function logAliveWritersInTheirForties() {
// write your code here
}

/* ======= TESTS - DO NOT MODIFY =====
- To run the tests for this exercise, run `npm test -- --testPathPattern 1-writers.js`
- To run all exercises/tests in the mandatory folder, run `npm test`
- (Reminder: You must have run `npm install` one time before this will work!)
*/

test("exercise 1", () => expectFunctionToLog(logAllWriters, [
"Hi, my name is Virginia Woolf. I am 59 years old, and work as a writer.",
"Hi, my name is Zadie Smith. I am 40 years old, and work as a writer.",
"Hi, my name is Jane Austen. I am 41 years old, and work as a writer.",
"Hi, my name is Bell Hooks. I am 63 years old, and work as a writer.",
"Hi, my name is Yukiko Motoya. I am 49 years old, and work as a writer."
]));

test("exercise 2", () => expectFunctionToLog(logDeadWritersInTheirForties, [
"Writer Jane Austen died at 41 years old."
]));

test("exercise 3", () => expectFunctionToLog(logAliveWritersInTheirForties, [
"Hi, my name is Zadie Smith. I am 40 years old.",
"Hi, my name is Yukiko Motoya. I am 49 years old."
]));

function expectFunctionToLog(f, values) {
const consoleLogSpy = jest.spyOn(console, 'log');
f();
expect(consoleLogSpy).toBeCalledTimes(values.length);
values.forEach((value, i) => {
expect(consoleLogSpy).nthCalledWith(i+1, value);
});
consoleLogSpy.mockRestore();
};
80 changes: 32 additions & 48 deletions mandatory/8-cheap-diner.js → mandatory/10-cheap-diner.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ chosenMeal(setOne)

Should give the answer "Lobster"

If given an empty array, return null.
If given an empty array:

let emptyArray = []
chosenMeal(emptyArray)
Expand All @@ -30,66 +30,50 @@ Should give the answer "Nothing :("
**/

function chooseMeal(mealArray) {
// Write your code here
}

/*
==================================================
====== TESTS - DO NOT MODIFY BELOW THIS LINE =====
==================================================
/* ======= TESTS - DO MODIFY (!!!) =====
- To run the tests for this exercise, run `npm test -- --testPathPattern 10-cheap-diner.js`
- To run all exercises/tests in the mandatory folder, run `npm test`
- (Reminder: You must have run `npm install` one time before this will work!)
*/
const util = require("util");

function test(test_name, actual, expected) {
let status;

if (actual === expected) {
status = `PASSED! You got the correct answer of ${util.inspect(expected)}`;
} else {
status = `FAILED: expected: ${util.inspect(
expected
)} but your function returned: ${util.inspect(actual)}`;
}

console.log(`${test_name}: ${status}`);
}

test(
"Test 1",
chooseMeal([
test("Meal to select is last", () => {
expect(chooseMeal([
{ name: "Dunkin' Donuts", price: 8.99 },
{ name: "Captain D's", price: 13.99 },
{ name: "Moe's Southwest Grill", price: 10.99 },
]),
"Moe's Southwest Grill"
);
])).toEqual("Moe's Southwest Grill");
});

test("Meal to select is first", () => {
expect(chooseMeal([
{ name: "Moe's Southwest Grill", price: 10.99 },
{ name: "Dunkin' Donuts", price: 8.99 },
{ name: "Captain D's", price: 13.99 },
])).toEqual("Moe's Southwest Grill");
});

test(
"Test 2",
chooseMeal([
test("Meal to select is also most expensive", () => {
expect(chooseMeal([
{ name: "Burger King", price: 8.99 },
{ name: "Wingstop", price: 9.99 },
]),
"Wingstop"
);
])).toEqual("Wingstop");
});

test("Test 3", chooseMeal([{ name: "Subway", price: 8.99 }]), "Subway");
test("Only one meal to select", () => {
expect(chooseMeal([{ name: "Subway", price: 8.99 }])).toEqual("Subway");
});

test("Test 4", chooseMeal([]), "Nothing :(");
test("No meals to select", () => {
expect(chooseMeal([])).toEqual("Nothing :(");
});

test(
"Test 5",
chooseMeal([
test("Meal to select is second cheapest, not second most expensive", () => {
expect(chooseMeal([
{ name: "Church's Chicken", price: 8.99 },
{ name: "Smoothie King", price: 109.99 },
{ name: "Jamba Juice", price: 38.44 },
{ name: "Jason's Deli", price: 22.77 },
]),
"Jason's Deli"
);

test(
"Test 6",
chooseMeal([{ name: "Church's Chicken", price: 8.99 }]),
"Church's Chicken"
);
{ name: "Jamba Juice", price: 38.44 },
])).toEqual("Jason's Deli");
});
Loading