App Lab — Part 2
Program Flow
If this was your first introduction to programming. Then I’m sorry that you’ve just had a brutal two weeks. This exercise is designed to help get you coding as many small examples as possible, it will help you become comfortable writing syntax and controlling your program’s flow
Before we begin, recall the lessons from lab 2 regarding control flow:
- There is something called conditional program flow, these are ways that expressions can be evaluated to produce different output.
- There are a few workhorse statements in JavaScript that help us direct the computer to do different things based on different conditions, these include: the
ifstatement, theelsestatement and theswitchstatement - There are also a number of iterative statements that help us do things multiple times such as the
whiledo, andforstatements. We call these loops.
Instructions
Below are some fun (ha!) programming challenges.
- Create a new folder called
lab2under your existingapplabgit repository - Complete one of the challenges below (choose one)
Challenge 1
Write a program that outputs the following to the console:
#
###
#####
#######Challenge 2
You noticed that people who enter the coffee shop holding their phones tend to get their drinks faster. Create a program that could help you estimate the time it would take someone to get their drink based on two boolean variables: holdingPhone and isAlone the output of the program should be in the form of:
Estimated drink time: 1.2 minutesWhere 1.2 above is calculated by your program.
Note: Don’t be ashamed to do what most programmers do (go to www.stackoverflow.com) if you need help or inspiration

