Skip to content

Commit

Permalink
Merge pull request #624 from vreynolds/fix-js-snake-docs
Browse files Browse the repository at this point in the history
fix up JS snake game instructions
  • Loading branch information
rachelmyers committed Feb 10, 2018
2 parents 622e420 + 59f13f3 commit a74f8cf
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/site_extensions/javascript-snake-game.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def js_expected_results(lesson)

source_code :js, File.read(src_path)

h4 'How the game should work:'
h4 'How the game should work so far:'

canvas id: 'chunk-game', height: '600', width: '800'

Expand Down
19 changes: 18 additions & 1 deletion sites/en/javascript-snake-game/lesson-2.step
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,26 @@ js_expected_results 'lesson-2'
MARKDOWN
end

step "Comments" do
markdown <<-MARKDOWN
Sometimes it's nice to leave a clarifying note to future readers of the code (this could very well be you!) in plain English. This is called a comment, and it is only intended for humans to read, the computer knows to ignore them.
Here's what comments look like in JavaScript:

```js
// this is a one line comment, here we're creating an array
var drawableObjects = [drawableSnake];
/*
this is a multi line comment
here we're drawing the snake
*/
CHUNK.draw(drawableObjects);
```
MARKDOWN
end

step "Play Time!" do
markdown <<-MARKDOWN
* Add comments underneath each line explaining what it does in plain old english.
* Add comments above each line explaining what it does in plain old english.
* Change the color of the snake.
* Make the snake longer than just 1 segment!
* Draw something in addition to the snake. Perhaps an apple or a wall? Make
Expand Down
19 changes: 19 additions & 0 deletions sites/en/javascript-snake-game/lesson-6.step
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,25 @@ MARKDOWN
js_expected_results 'lesson-6'

markdown <<-MARKDOWN
### Switch statement

A `switch` statement is another way to organize a seried of `if` and `else if`s. Here's an example:

```js
switch(color) {
case "red":
return { action: "stop" };
case "orange":
return { action: "wait" };
case "green":
return { action: "go" };
default:
return { action: "unknown" };
}
```

Can you figure out how to replace our snake game code above with a `switch` statement? (Don't worry, you'll see how we do it in the next lesson)

### Play Time!

* Use a switch statement instead of a series of ifs
Expand Down

0 comments on commit a74f8cf

Please sign in to comment.