Parameters
Return
Only Code Tracing questions
Miscellaneous
100

What is the purpose of a parameter in a function?

A parameter allows a function to accept input values so it can operate on different data each time it is called(multiple ways to answer this)

100

What is the purpose of a return statement in a function?

It sends a value back to the caller of the function.

100

What is the output:

function square(n) {  
return n * n; 
}
console.log(square(3) + square(4));


25

100

What are three consecutive strikes in bowling called?

Turkey

200

What is the difference between a parameter and an argument?

A parameter is a variable defined in the function to accept input; an argument is the actual value passed when calling the function.

200

What will this code output?

function add(a, b) {
  return a + b;
 }
console.log(add(2, 3));


5

200

What is printed?

console.log(72%4);

0, 4 goes into 72 evenly.

200

What does HTTP stand for?

Hypertext Transfer Protocol

300

List at least 5 possible parameters for a function called makePizza()

answers may vary

300

What is the output?

function checkEven(n) { 
 if (n % 2 === 0) {  
  return true;  
else { 
   return false; 
 } 
}
console.log(checkEven(7));


false

300

Predict the output:

function mystery(num) {
  var result = 0;  
for (var i = 0; i < num; i++) { 
   result += i;  
 return result;
 }
console.log(mystery(5));


10 (0 + 1 + 2 + 3 + 4 = 10)

300

Name the three main types of rock in geology.

Igneous, Sedimentary, Metamorphic

400

function combine(a, b ) {

  return a + b;

}

console.log(combine(5,0));

console.log(combine(3, 10));



5 // 5 + 0 = 5

13  // 3 + 10 = 13

400

This function finds the largest number in a list. What should replace <MISSING CODE>?

function findMax(list){

    var max = list[0];

    for(var i = 0; i < list.length; i++){

        if(list[i] > max){

            <MISSING CODE>

        }

    }

    return max;

}

 max = list[i];

400

What does this code print?

function func(a, b) { 
 return a - b; 
}

var x = 10;
var y = func(x, 4);
console.log(y + 2);


8

400

Name the professional MLB and NBA teams that represent the city of Toronto

Blue Jays, Raptors

500

What will this code print? 

function mystery(n) {
var result = 0;
for (var i = 1; i <= n; i++) {  
  if (i % 2 == 0) {
      result += i;   
 } 
 } 
 return result;
 }

console.log(mystery(7));



12

500

What does this code print? Explain why.

function tricky(num)
 { 
 var result = 1; 
 for (var i = 1; i <= num; i++) {  
 result *= i;  
}  
return result; 
}
console.log(tricky(5));



120 (This calculates 5! = 12345)

500

function sum(n) {

  var total = 0;

  for (var i = 1; i <= n; i += 2) {

    total += i;

  }

  return total;

}

console.log(sum(10));


 25 (1 + 3 + 5 + 7 + 9 = 25)

500

What is the signature food dish served at Wimbledon?

Strawberries and cream