-
Answer the following questions with the person sitting next to you:
- What does a function return by default?
- What is the
return
keyword? What does it do? - Do you always have to give a function a name?
- What is the difference between this:
myFunctionName
andmyFunctionName()
? - What is the function signature?
-
Create a function which takes the arguments
name
andjobTitle
.- The function should return a string which is something like
"Sam works as a Support Analyst"
.
- The function should return a string which is something like
-
Create a function called
vacationPlanner
- it takes three arguments:
destination
(String),budget
(Number),totalCost
(Number) - if the
totalCost
exceeds the budget, the function should return:"Sorry, but you need X$ more to go to Y."
where X is the amount you are short, and Y is the destination you wanted to go to. - if the
budget
is equal to or more than thetotalCost
, return:"Pack your bags! You are going to Y with an extra spending budget of X$!"
where Y is the destination, and X is how much you're budget exceeds the totalCost - if passed no arguments, it returns
"Are you sure you just want to stay home?"
- it takes three arguments:
Created
May 4, 2017 18:18
-
-
Save biglovisa/063391d11804f688890afe618a358428 to your computer and use it in GitHub Desktop.
Class 2: exercises
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment