Session Plan

The trainees really struggle with the return value. What it means, how it is captured. What happens when nothing is returned etc. Try really hammering in this concept with lots of simple examples and exercises! e.g. if a function is called get something. That means that something is returned from that function.

Zoey Zou made a nice Notion session plan here: https://www.notion.so/JS1-Week2-8f2d4b7e7ba0425ea4a9e97816e9ceb7

Flipped classroom videos

Flipped classroom videos

Code inspiration

if statements

Functions

if and function

Scope

for loop

Exercises

if statements exercise

Use if statements to give a user a message based on their bank account balance. Use the balance variable and change that.

  • If a user has 0 or less balance log out 'Please deposit some money!'

  • If a user has more than 0 and at most 1000 log out 'Your balance is looking okay'

  • If a user has more than 1000 and at most 3000 log out 'Your balance is looking good'

  • If a user has more than 3000 and at most 10000 log out 'Your balance is fantastic'

  • If a user has more than 10000 log out 'Your balance is AMAZING!'

Function

Create a function called getCircleArea. It should have the radius of the circle as parameter and return the circle area. What happens if we don't return anything in the function?

Create a function called celsiusToFahrenheit it should have a parameter called celsius. It should return the temperature in fahrenheit.

Try call the function and check with google if the function returns the right value.

Exercise: Scope

With pen and paper write what is logged out.

for loop exercises

Simple for loop

Create a for loop that logs out the numbers from 74 - 98

for loop in a function

Create a function that has two parameters: stringToLog and numberOfTimesToLog

When calling the function it should log out the stringToLog the amount of times specified in numberOfTimesToLog. Use a for loop.

Send emails

Imagine we work at a company. Anna from the HR department wants us to send out a couple of emails to some recipients. The only problem is that she sent us the email in a weird format: [email protected]|[email protected]|[email protected]|[email protected]|[email protected]|[email protected]|[email protected]

Use the sendEmailTo function to send an email to all the recipients that we got from Anna.

Hint use the .split method and look up iterating an array js for loop on google.

Last updated