WorksheetsCode.org Coding Lessons 4-6
Total questions: 10
Worksheet time: 13mins
What is the correct format to define a function?
Note: The name of the Function is "multiplyBy2"
multiplyBy2();
function multiplyBy2(){
//steps to execute function
}
function multiplyBy2
multiplyBy2{5}{
//steps of function
}
What makes the following command invalid: turnleft();
It should end in a colon rather than a semicolon
The letter l should be capitalized - L
It should start with a capital T
The command is correct
Why do we use functions in programs?
A. Make the program easier to read
B. Avoid retyping the same lines of code
C. Both A and B are correct
D. Neither A nor B are correct
In this code, how many times is the "dance" function called and how many times is it defined?
called 1 time, defined 1 time
called 1 time, defined 3 times
called 3 times, defined 1 time
called 3 times, defined 3 times
(assume the function name is doStuff)
//list of steps to execute
}
