-
Notifications
You must be signed in to change notification settings - Fork 3
v5 Week 01 JavaScript Basics and Functions
| Week | Topic | Learning Objectives | Key Resources |
|---|---|---|---|
| 1 | JS Basics and Functions | Students will be able to fork a Replit file; declare string, numerical, and boolean variables; practice with concatenating strings; and complete basic math problems. | Week 1 Slides |
| Students will be able to encapsulate code with functions, pass information into functions, and practice with arrow functions. | Week 2 Slides TBD |
Here is an overview of what students cover this week:
-
- Problem solving is the most important programming skill. To solve a problem, first understand it completely by restating it in plain language. Next, plan the solution by sketching the UI, identifying inputs/outputs, and writing out the step-by-step algorithm in pseudo code.
- Break big problems down into subproblems. Start by solving the smallest subproblem. Solving each subproblem will reveal the next or make the next one easier to solve. Decomposing big problems into smaller ones is the main way to manage complexity.
- Practice building lots of programs to improve problem solving skills. The quantity of practice is important. Don't try to solve one big complex problem in one go. Break it down and divide-and-conquer.
-
- Variables are "storage containers" for data and can be declared using var, let, or const. Numbers are important for math operations. Use operators like +, -, *, / and % to perform math on numbers.
- You can add, subtract, multiply, divide, increment, decrement numbers and variables containing numbers. Be careful when mixing numbers and strings. Follow order of operations.
- Access browser developer tools to view the console. Print to the console with console.log(). Practice math and variables here before adding to webpages. Unary plus converts strings to numbers.
-
- Strings represent text and have built-in methods like replace(), slice(), etc. Use single, double, or backtick quotes for strings. Join strings together with +.
- Conditionals allow you to control program flow based on comparisons (> , < , ==, etc). Logical operators (&&, ||, !) combine conditions. if/else, switch, and ternary (? :) conditionals exist. Practice using strings, logical/comparison operators, and if/else conditional statements. Concatenate strings, embed variables into strings. Understand truthy/falsy values. Nest conditionals for complex logic.
-
- The key goals are to practice core language fundamentals, use comments/console logs effectively, and write conditional logic.
- Students should watch out for small syntax issues, data type and conversion errors, and make sure to break down complex math concepts.
-
- Functions bundle reusable code into callable packages. Define with
function name() {}and call withname(). Can pass data in as parameters and return data out. - Functions create local scope for variables. Use return to pass data out of a function back to caller. Can also return function calls.
- Arrow functions
() => {}are a shorthand form for defining functions. Understand function call stack and order of operations when chaining function calls.
- Functions bundle reusable code into callable packages. Define with
-
Practice with date and time functions
- Create Date objects, access and modify date components like day, month, year, hours, etc. Calculate differences between dates in milliseconds. Format dates as strings.
- Get the current date and time with new Date() and Date.now(). Use date methods like getDay(), getHours(), etc. and set methods like setDate() to manipulate Date objects.
- Benchmark date functions for speed comparisons. Pass dates into functions as arguments. Be aware of browser optimizations when microbenchmarking.
- Code the Dream's curriculum uses materials from Project Odin, an open-source text curriculum, and Scrimba for video content. Some returning students might be used to Treehouse; we replaced Treehouse with Scrimba in January 2024.
- Since this is the first week of "real" content, you might see many students for the first time in your mentor sessions. Put lots of effort these first few weeks into relationship-building. It will pay off in the long run if students feel comfortable and safe in your mentor sessions. Check the Big Picture Resources page for ideas on making students feel comfortable in the sessions.
Potential FAQs or trouble spots from this week include:
- Students may have lots of questions early on about expectations. As a quick reminder:
- Students should attend at least one mentor session each week.
- Deadlines are "soft" – there is no penalty for turning in an assignment late – but students who get 2+ weeks behind are very unlikely to finish the class.
- Scrimba is free for students - if it asks them to pay, they should go back and click the coupon code link Mary Alice sent them!
- Common trouble spots here revolve around syntax, scope, data types/casting, conditionals and user inputs. Students should take it slow, use console logging, handle errors correctly, and ask for help early when stuck!
Grading this first week should be pretty straightforward! You can mark the student's assignment as complete if they:
-
Have forked the Replit file and submitted their assignment.
-
console.loginputs properly for each of the 15 questions. -
Use proper syntax and good JavaScript logic to solve each question. Example answers link. (Note that some student variation is expected!)
-
Use proper syntax and good JavaScript logic to answer the questions. Example outputs: (Note that some student work variation is expected!)
- Q1:
Welcome to Code the Dream! - Q2:
[Current month] - Q3:
Good Evening - Q4:
[ANY ALL-CAPITALIZED TEXT] - Q5:
I changed thisandI started this - Q6:
10(Can be other numbers - should be a multiplication!) - Q7:
3.5(Can be other numbers – should be an average!) - Q8:
console.log("Q8 neg num: ", absDiff(-6, 5)would yieldQ8 neg num: 11 - Q9:
5(Can be other numbers - should be longest string) - Q10:
41(Should display number of days until birthday) - Q11:
2 hours and 42 minutes(Should display time difference) - Q12: Variable student answers.
- Q1:
The Intro Guidebook is created by Code the Dream staff and volunteers for Code the Dream volunteers. This is your tool – please feel free to suggest edits or improvements.
Overview of the wiki.
Onboarding guide for new volunteers.
Links to pages for specific assignments, including rubrics, overviews of student content, and mentor-created resources.