- In your own words, what is the purpose of a function?
A function is a set of statements that performs a task or calculates a value when the function is referenced or called.
- What is a parameter?
A parameter is a variable used to specify what the function should do or calculate.
- What is a return value?
The return value is the answer you get from a function.
- In the space below, create a function named
hello
that will print"Sam I am"
.
function hello() {
console.log("Sam I am");
}
hello();
- Create a function name
hello_someone
that takes an argument ofname
and logsname + " I am"
.
function hello_someone(name) {
console.log(name + "I am");
}
hello_someone("Bob");
- How would you call or execute the function that you created above?
hello_someone("Bob");
- What questions do you still have about functions in Javascript?
I know these lines are clunky but not 100% sure how to explain what's wrong with them compared to the ones in my functions.js document:
function myName(name) {
return name;
}
var name = "Hanna Kim"
console.log(myName(name));
// ----------------- //
function knockKnock(orange, banana) {
console.log(orange + " " + banana);
}
var orange = "Orange you glad";
var banana = "I didn't say banana";
console.log(knockKnock(orange,banana));
Also: Rule #3 from the reading in README.md would not execute.