Skip to content

Instantly share code, notes, and snippets.

@wofockham
Created March 31, 2014 03:34
Show Gist options
  • Select an option

  • Save wofockham/ca4436912c58c7300f27 to your computer and use it in GitHub Desktop.

Select an option

Save wofockham/ca4436912c58c7300f27 to your computer and use it in GitHub Desktop.

#Title: Currency Converter App

###Summary Get used to syntax and using variables and functions in JavaScript

###Objectives:

  • create and use variables
  • create and use functions

###Activity:

Converting dollars to pounds:

  • Store a dollar amount into a variable.
  • Convert it to pounds and output "$NN is £NN".

Converting pounds to dollars:

  • Now store a pound amount into a variable.
  • Convert it to dollar and output "£NN is $NN."

Cleaning it up:

  • Can you make sure the output is only 2 decimal places?

Refactoring

  • Can you refactor the code so that it uses functions? Write a function dollarsToPounds that takes a dollar number as input and outputs a string of what the pound equivalent is.
  • Do the same for poundsToDollars
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment