What does a function do in your code?
What is it runs a set of instructions?
How do you “run” a function?
What is by calling it with ()?
Why would a ninja use a function in their code dojo?
What is to organize their code like a master?
What’s wrong?
function sayHi {
console.log("Hi!");
}
What is missing the () after sayHi?
Create a function that says “Code Rocks!”
function cheer() {
console.log("Code Rocks!");
}
What is the name of the part where you write what the function does?
What is the function body?
What will this code print?
function ninja() {
console.log("Slice!");
}
ninja();
What is Slice!?
What real-life activity is like a function?
What is following a recipe?
What’s wrong with this function call?
greet;
What is it's missing () — should be greet();
Make a function named clap() that prints 👏👏👏
function clap() {
console.log("👏👏👏");
}
What word do we use to start making a function in JavaScript?
What is function?
If a function is named jump, how do you use it?
What is jump();?
True or False: A light switch is like a function.
What is true!
Find the bug:
function dance() {
console.log("Dancing")
What is missing the closing }?
Write a function that adds 2 numbers and logs the result.
function add(a, b) {
console.log(a + b);
}
What do we call the name and inputs of a function?
What is the function header?
What happens if you forget the () when calling a function?
What is the function doesn’t run?
What’s a good name for a function that makes your ninja jump in a game?
What is jumpNinja() or doJump()?
What’s wrong?
function doMath(x, y) {
return x + y;
}
doMath(3);
What is it's missing a second argument?
Write a function that says “Good job, Ninja [name]!”
function praise(name) {
console.log("Good job, Ninja " + name + "!");
}
What does the word "return" do in a function?
What is it sends a value back?
Can you call a function inside another function?
What is yes!
If your ninja does karate moves, what could the function be called?
What is karateKick() or performMove()?
What’s wrong?
function double(x) {
return x x;
}
What is it needs an operator like x * 2?
Create a function that returns the area of a rectangle (length × width).
function getArea(length, width) {
return length * width;
}