Media Computation Skills Lab

MTEC 1003 - Fall 2016

Lab 6 - JavaScript Conditionals

In this lab, you’ll be creating several programs:

  1. cake
  2. spanish
  3. odd calculator

Summary of Commands:

THESE ARE NOT LAB INSTRUCTIONS.

The following is just a reference. The lab instructions are below.

# create a local repository
git init

# configure it with your name and email
git config user.name  "your name"
git config user.email "your@email.address"

# create a remote repository
curl -u 'your github user name' https://api.github.com/user/repos -d '{"name":"your repository name"}'

# link the two
git remote add origin "your username"@"the url to your repository on github"

# two ways to show all remote repositories
git remote -v
cat .git/config

# removing a remote repository by name (usually origin)
git remote remove name_of_remote

# changing / setting the url of a named remote repository (usually origin)
git remote set-url name_of_remote new_remote_url

# look at the differences between your last save and your current changes (line by line)
git diff --color

# check on the status of your changes
git status

# "stage" or mark your changes as ready to be saved
git add --all

# save!
git commit -m 'my message'

# show a log of your changes so far
git log --color (show your changes so far)

# send to a remote repository (to submit an assignment)
git push origin master 

Instructions

Note that ALL OF THESE FILES MUST BE CREATED IN THE REPOSITORY THAT YOU CREATED FOR THIS LAB.

cake

Write a program that asks the user if they want cake. Based on the response, it will output a different message to the JavaScript Console.

# Run 1
(prompt) Do you want cake?
> yes
Have some cake.
# Run 2
(prompt) Do you want cake?
> maybe
No cake for you.
# Run 1
(prompt) Do you want cake?
> no
No cake for you
# Run 2
(prompt) Do you want cake?
> maybe
I don't understand

spanish

Write a program that translates english words to Spanish.

# Run 1
(prompt) Give me a word in English...
> gato
cat
# Run 2
(prompt) Give me a word in English...
> bear
no entiendo

odd calculator - oddcalc.html

Prompt the user for a number.

Prompt the user for another number.

Ask the user what kind of operation they want to do - mult, div, or mod.


guess *** extra credit ***

Write a number guessing game! “Hardcode” a secret number. Ask the user to guess the secret number. If they are correct, say “You got it!”. If they are within 1, say “Close, but the number is (the secret number)”. Lastly, if they were totally incorrect, then say, “The number is (the secret number)”. Look up the parseInt function to convert the input into a number so that your comparisons work.

MTEC 1003 - Media Computation Skills Lab - Spring 2015