-
-
Notifications
You must be signed in to change notification settings - Fork 4
Make all IDs more semantic #32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
illicitonion
wants to merge
2
commits into
main
Choose a base branch
from
update-ids
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -301,13 +301,13 @@ <h2>Creating html dynamically: lists of fruit</h2> | |
| <ol> | ||
| <li>Let's start with an html list with a single apple in the "Static html" | ||
| <ol> | ||
| <li>Note the list has an id ("list") so that we can refer to it from our program.</li> | ||
| <li>for example: <code class="start_code"><ul id="list"><br><li>Apple</li><br></ul></code></li> | ||
| <li>Note the list has an id ("fruits") so that we can refer to it from our program.</li> | ||
| <li>for example: <code class="start_code"><ul id="fruits"><br><li>Apple</li><br></ul></code></li> | ||
| </ol> | ||
| <li>Add one more fruit dynamically | ||
| <ol> | ||
| <li>Add an <span class="blockname">"at the start"</span> block</li> | ||
| <li>Inside this block, add a <span class="blockname">"find the element with id"</span> block using the id for the ul element (<code>list</code>)</li> | ||
| <li>Inside this block, add a <span class="blockname">"find the element with id"</span> block using the id for the ul element (<code>fruits</code>)</li> | ||
| <li>Inside this block, add a <span class="blockname">"create a new ... element"</span> block and select "<li>"</li> | ||
| <li>Inside this block, add a <span class="blockname">"set the text content"</span> block and set the value to "Banana"</li> | ||
| <li id="exercise_add_fruit_1">Click "run" to check the output looks like | ||
|
|
@@ -362,7 +362,7 @@ <h2>Creating html dynamically: lists of links</h2> | |
| This exercise consolidates the use of the blocks we learned about in the previous exercises. | ||
| </p> | ||
| <ol> | ||
| <li>Start with an empty unordered html list (<code class="start_code"><ul id="list"></ul></code>) in the static html. | ||
| <li>Start with an empty unordered html list (<code class="start_code"><ul id="links"></ul></code>) in the static html. | ||
| <li>Dynamically add your favourite links to the html list | ||
| <ol> | ||
| <li>Find the URLs of your three favourite websites (they look something like: <code>http://www.codeyourfuture.io</code>)</li> | ||
|
|
@@ -436,7 +436,7 @@ <h2>Buttons and clicks: A button to add apples</h2> | |
| <ol> | ||
| <li>Start with an empty unordered html list (<code><ul></code>) and a button to add apples to the list (<code><button></code>) in the static html. | ||
| <ol> | ||
| <li>for example: <code class="start_code"><ul id="list"></ul><br><button id="button">add an apple</button></code></li> | ||
| <li>for example: <code class="start_code"><ul id="fruits"></ul><br><button id="add-apple-button">add an apple</button></code></li> | ||
| </ol> | ||
| <li>When we click on the "add an apple" button, let's add an apple to the list | ||
| <ol> | ||
|
|
@@ -480,7 +480,7 @@ <h2>Inputs and clicks: say something</h2> | |
| <ol> | ||
| <li>Start with a text input box list (<code><input /></code>) and a button to that says "speak" in the static html. | ||
| <ol> | ||
| <li>for example: <code class="start_code"><input id="text" /><br><button id="button">speak</button></code></li> | ||
| <li>for example: <code class="start_code"><input id="text-to-say" /><br><button id="speak-button">speak</button></code></li> | ||
| </ol> | ||
| </li> | ||
| <li>We want to do two things in order when the button is clicked. First we get the value entered by the user, then we pass it to a block that will say it out loud. A common strategy in problem solving for programming is to solve the visible (or in this case, audible) thing first: have the browser say something. | ||
|
|
@@ -530,7 +530,7 @@ <h2>Buttons, inputs and clicks: a todo list</h2> | |
| We're going to create a list of things to do. | ||
| </p> | ||
| <ol> | ||
| <li>Start with an empty list, an input, and a button "add Todo Item" in the static html. <code class="start_code"><p>Things to do:</p><br><ul id="list"></ul><br><input id="text" /><br><button id="button">add Todo Item</button></code></li> | ||
| <li>Start with an empty list, an input, and a button "add Todo Item" in the static html. <code class="start_code"><p>Things to do:</p><br><ul id="todo-list"></ul><br><input id="new-todo" /><br><button id="add-todo">add Todo Item</button></code></li> | ||
| <li>When the button is clicked, we are going to do two things: get the value of the input box and add a new <code><li></code> with that value to the list. To do the visible outcome first, we're going to do these in reverse order.</li> | ||
| <ol> | ||
| <li>Add an <span class="blockname">"when the element with id ... is clicked"</span> block.</li> | ||
|
|
@@ -609,7 +609,7 @@ <h2>Variables: keeping track of the number of clicks</h2> | |
| A variable is a name into which a value can be stored. There are several reasons for which we might want to do this. The first is when we want to keep track of a value that changes over time. Let's keep track of the number of times a button is clicked. | ||
| </p> | ||
| <ol> | ||
| <li>Start with a button (<code><button></code>) that has been clicked 0 times in the static html. <code class="start_code"><button id="button">0</button></code></li> | ||
| <li>Start with a button (<code><button></code>) that has been clicked 0 times in the static html. <code class="start_code"><button id="counting-button">0</button></code></li> | ||
| <li>Add an <span class="blockname">"at the start"</span> block. Inside we are going to add a variable that will keep track of the number of times the button was clicked.</li> | ||
| <ol> | ||
| <li>In the Variables menu, click "create variable..." to create a variable called <code>click_count</code></li> | ||
|
|
@@ -659,7 +659,7 @@ <h2>Variables consolidation: counting sheep</h2> | |
| Let's combine our variables to track state with some of the other blocks we have learned about. We would like to track how many times the user adds the word "sheep" and how many times they add any other word. | ||
| </p> | ||
| <ol> | ||
| <li>Let's start with the following static html. <code class="start_code"><p>There have been <span id="sheep_count">0</span> sheep 🐑 and <span id="other_count">0</span> others.</p><br><input id="text" /><br><button id="button">add animal</button></code></li> | ||
| <li>Let's start with the following static html. <code class="start_code"><p>There have been <span id="sheep_count">0</span> sheep 🐑 and <span id="other_count">0</span> others.</p><br><input id="animal-kind" /><br><button id="add-animal-button">add animal</button></code></li> | ||
| <li>The following things should happen (use variables where necessary to keep track of various values, and the blocks you need from the Logic menu). Don't forget to break down your implementation into steps where you first add blocks that make a visible difference and test that it works.</li> | ||
| <ol> | ||
| <li>When the user clicks "add animal", if the word in the text input is "sheep", the number of sheep displayed in the <code><span></code> with id <code>sheep_count</code> should increase by one.</li> | ||
|
|
@@ -800,7 +800,7 @@ <h2>Arrays and loops</h2> | |
| Another use for an array is when we want to do the same thing with each element in an array (for example, create a <code><li></code>). | ||
| </p> | ||
| <ol> | ||
| <li>Start with an empty unordered html list with the id "list" (<code class="start_code"><ul id="list"></ul></code>) in the static html.</li> | ||
| <li>Start with an empty unordered html list with the id "fruits" (<code class="start_code"><ul id="fruits"></ul></code>) in the static html.</li> | ||
| <li>Add an <span class="blockname">"at the start"</span> block</li> | ||
| <li>We'll now create an array of fruits and assign it to a variable <ol> | ||
| <li>From the "Arrays" menu, add a <span class="blockname">"Set ... to, create array with"</span> block to the <span class="blockname">"at the start"</span> block</li> | ||
|
|
@@ -945,7 +945,7 @@ <h2>Arrays and buttons</h2> | |
| <div class="instructions"> | ||
| <p>The most common something with all the items in an array is to use a loop, as we saw in the previous exercise. Sometimes, a loop just doesn't do what we need, for example if we wanted to make the list of fruit appear gradually.</p> | ||
| <ol> | ||
| <li>Create an empty unordered html list (as usual) and a "reveal next fruit" button (<code class="start_code"><ul id="list"></ul><br><button id="button">reveal next fruit</button></code>)</li> | ||
| <li>Create an empty unordered html list (as usual) and a "reveal next fruit" button (<code class="start_code"><ul id="fruits"></ul><br><button id="reveal-fruit-button">reveal next fruit</button></code>)</li> | ||
| <li>Create an array of your favourite fruit inside an <span class="blockname">"at the start"</span> block</li> | ||
| <li>We'll now make it so each click of the button reveals the next fruit. | ||
| <ul> | ||
|
|
@@ -1067,7 +1067,7 @@ <h2>Loops and arrays: more fun with fruit</h2> | |
| <div class="instructions"> | ||
| <p>Using the blocks from the previous exercise and a different kind of loop gives us an alternative way to loop through all the items of an array. Let's see a case where it might be useful.</p> | ||
| <ol> | ||
| <li>Start with an empty unordered html list with the id "list" (<code class="start_code"><ul id="list"></ul></code>) in the static html.</li> | ||
| <li>Start with an empty unordered html list with the id "fruits" (<code class="start_code"><ul id="fruits"></ul></code>) in the static html.</li> | ||
| <li>As with before, create an array called "fruits" of your favourite fruit inside an <span class="blockname">"at the start"</span> block.</li> | ||
| <li>Instead of the <span class="blockname">"for each item in array"</span> block, we will use the <span class="blockname">"repeat while"</span> block and the <span class="blockname">"... is empty"</span> block together<ol> | ||
| <li>As usual, add a <span class="blockname">"find the element with id"</span> block to find the html list</li> | ||
|
|
@@ -1187,7 +1187,7 @@ <h2>Arrays: Adding, removing, and summing elements</h2> | |
| <p>We are now going to learn how to add items to, remove items from, and get the sum of, an array of numbers. We're going to keep a running sum of the last five numbers (this can be a way of keeping track of how a value trends over time, e.g. the last 5 times you weighed yourself, or the last 5 times you went running). | ||
| </p> | ||
| <ol> | ||
| <li>Start with an input box, a button to add numbers, and a span to display the total. (<code class="start_code"><p>Total of the last 5 numbers: <span id="total"></span> </p><br><input id="number" /><br><button id="add_number">add value</button></code></li> | ||
| <li>Start with an input box, a button to add numbers, and a span to display the total. (<code class="start_code"><p>Total of the last 5 numbers: <span id="total"></span> </p><br><input id="number" /><br><button id="add-number">add value</button></code></li> | ||
| <li>Let's start with an array of elements and show their sum<ol> | ||
| <li>In an <span class="blockname">"at the start"</span> block, create a new array called "numbers" with 5 items, all set to the value 0</li> | ||
| <li>Find the span with id "total" and set its text content to the sum of the numbers array, using the <span class="blockname">"get the sum of the numbers in array"</span> block</li> | ||
|
|
@@ -1290,7 +1290,7 @@ <h2>Project: Don't go higher than 11!</h2> | |
| <p>We are now going to use all the array blocks we have learned about. We're going to create a game where you roll dice and your goal is to not total more than 11. | ||
| </p> | ||
| <ol> | ||
| <li>Start with an empty list (where we will display our rolls), a place to put a total, and a few buttons (<code class="start_code"><p>So far you have rolled:</p><br><ul id="list"></ul><br><button id="button_roll">Roll the dice</button><br><p>Total: <span id="total">0</span>. <span id="info">Keep playing!</span></p><br><button id="button_remove">Remove the last roll</button><br><button id="button_restart">Start again</button></code></li> | ||
| <li>Start with an empty list (where we will display our rolls), a place to put a total, and a few buttons (<code class="start_code"><p>So far you have rolled:</p><br><ul id="previous-rolls"></ul><br><button id="roll-button">Roll the dice</button><br><p>Total: <span id="total">0</span>. <span id="info">Keep playing!</span></p><br><button id="remove-roll-button">Remove the last roll</button><br><button id="restart-button">Start again</button></code></li> | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pretty sure all these ids are referred to later
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I couldn't see any... Do you see any specifically? |
||
| <li>The game has the following requirements. Before reading further, how would you break down and implement these requirements into steps? Think through what steps need to happen after each button click. In what order would you implement these steps so as to test each step as early as possible?<ul> | ||
| <li>When "roll the dice" is clicked, a new random number between 1 and 6 should be generated and added</li> | ||
| <li>If the total of all the dice rolls is exactly 11, display "You won" in the <code><span id="info"></code></li> | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are dashed ids a good practice (I know classnames are often dashed)? I would probably underscore them, to avoid teaching identifiers with - in them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have a super strong preference - I started dashing somewhat at random, so changed a few _s to -s because I'd done most of them, but happy to change them all to _s if you'd prefer :)