App Lab — Part 2

Program Flow

Christian Grewell
Sep 9, 2018 · 2 min read

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 if statement, the else statement and the switch statement
  • There are also a number of iterative statements that help us do things multiple times such as the while do, and for statements. We call these loops.

Instructions

Below are some fun (ha!) programming challenges.

  1. Create a new folder called lab2under your existing applab git repository
  2. 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:

Where 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

DUE NEXT TUESDAY EVENING ON GITHUB BEFORE 6:00PM

applab

materials, guides and readings for the upcoming NYU Shanghai Interactive Media Business course, App Lab

Christian Grewell

Written by

Hi! My name is Christian Grewell, I grew up in Portland, Oregon playing music, programming video games, building computers and drinking coffee. I live in China.

applab

applab

materials, guides and readings for the upcoming NYU Shanghai Interactive Media Business course, App Lab

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade