WEEK 3: JavaScript Functions
(January 23 & 25)

To Do This Week:

CodeAcademy – just the lessons, not the projects 
Learn Javascript :
4
. Functions“,
5. “
Scope”
6.” Arrays”
7. “Loops”

Read (optional): Eloquent Javascript


Class

JavaScript Talk:

Steps to make a Hangman game…?


Workshop 

Change Circles Script

Circles
Circles / Letters

Student Pairings

Download the Circles file (control click page) or get the source code and make a new file in Sublime text. Then, with your partner, make changes. First talk about what 3 things you want to change in the script. Then list the steps needed for each change. Try to find the JavaScript code. Use ChatGPT or ask me.

Remember, if your script stops working. Command + Option + J opens the console with the line of the error. Or “inspect element” and look for the Console in the panel. 


Traversing the DOM (getting and manipulating elements on the page):


Working with strings (manipulating text):

Regex (regular expressions) Basics:

// TO BREAK A LINE AFTER A PERIOD
// find all periods: \.
// replace with: \.\n

// TO ADD QUOTE AT START OF LINES
// find beginning of line: ^
// replace with: ”

// TO ADD QUOTE AND COMMA AT END OF LINES
// find end of line: $
// replace with: “,

// TO REMOVE ALL LINE BREAKS
// find: \n\s+
// replace with nothing

practice file