Skip to content

Instantly share code, notes, and snippets.

@wofockham
Created March 31, 2014 04:29
Show Gist options
  • Select an option

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

Select an option

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

##Exercises: if/else statements

###What number's bigger?

Write a function named greaterNum that:
takes 2 arguments, both numbers.
returns whichever number is the greater (higher) number.
Call that function 2 times with different number pairs, and log the output to make sure it works (e.g. "The greater number of 5 and 10 is 10.").

###The World Translator

Write a function named helloWorld that:
takes 1 argument, a language code (e.g. "es", "de", "en")
returns "Hello, World" for the given language, for atleast 3 languages. It should default to returning English.
Call that function for each of the supported languages and log the result to make sure it works.

###The Grade Assigner

Write a function named assignGrade that:
takes 1 argument, a number score.
returns a grade for the score, either "A", "B", "C", "D", or "F".
Call that function for a few different scores and log the result to make sure it works.

###The Pluralizer

Write a function named pluralize that:
takes 2 arguments, a noun and a number.
returns the number and pluralized form, like "5 cats" or "1 dog".
Call that function for a few different scores and log the result to make sure it works.
Bonus: Make it handle a few collective nouns like "sheep" and "geese".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment