Conditionals
Loops
JavaScript1
Functions
Miscellaneous
100
What is the "not equal" operator? Hint: The "equal" operator is ===
!==
100
What does a while loop do?
Allows code to be executed repeatedly based on a given true/false condition. The while loop can be thought of as a repeating if statement.
100
How do you declare a variable in JavaScript?

The length property. For example:


var variableName;
100
What are the values in between the parentheses called? Hint: The correct answer is not HERE.

function someFunction (HERE) {
    // code
}
arguments (or parameters)
100
In a CSS selector, how could you target an element that has id="example"?

HERE {
   width: 40px;
}
#example
200
What will this print?

var x = 25;
if(x < 10) {
    console.log("first");
} else if (x > 10) {
    console.log("second");
} else if (x === 25) {
    console.log("third");
} else {
    console.log("fourth");
}
second
200
What will this print?

    var num = 0;
    var i = 0;
    while(i < 4){
        num = num + i;
        i++;
    }
    alert(num);
6
200
List all of the JavaScript math operators you've learned and their names.
Addition +
Subtraction -
Multiplication *
Division /
Modulus %
200
Here I'm defining a new function. Write some code that calls it.

function callMe(value1, value2) {
    console.log("You passed in " + value1 + " and " + value2);
}
callMe(1, 2)
200
Give 2 ways to increment 1 to num on the next line after the comment.

   var num = Math.random();
   // Add 1 to num

num++

num = num + 1

num += 1

++num

300

What value could you set x to so "fourth" will be printed?

What value could you set x to so "third" will be printed?


if(x < 10) {
    console.log("first");
} else if (x > 10) {
    console.log("second");
} else if (x > 25) {
    console.log("third");
} else {
    console.log("fourth");
}
Setting x to 10 will print "fourth". There isn't a way to get "third" to print.
300
Write a while loop that console.log() the numbers 1-9.

  var i = 1;
  while(i < 10) {
     console.log(i);
     i++;
  }

300

  var x = 11;
  x = x + 3;
  console.log(x);
  x = 2;
What will console.log(x) output?
14
300
The teacher will open this jsbin:

http://jsbin.com/aLoBoGaP/1/edit?js,console

What will get printed when I hit Run?

Nothing will get printed
300
Name the 3 different types we've learned so far.
  • Strings
  • Numbers
  • Booleans
400
What will this print?

   var x = 3;
   if(x === "3") {
      console.log("true");
   }else{
      console.log("false");
   }
false
400
What will this print?

 var sum = 0;
 var i = 0;
 while(i < 5) { 
   sum = sum + i;
   i++;
 } 
 alert(sum);
10
400

  var x = 3;
  var y = 10;
  var xy = (x * y) /3;
What value does the variable xy hold?
10
400
Define a function that takes no arguments and uses alert to print "hello".

function myFunc() {
   alert("hello");
}
400

Give 2 ways to comment out code.

Hint: One way comments out a single line, while the other way can be used to comment out multiple lines.


// This comments out one line of code

/* And this comments out
   multiples lines
   of code
*/
500
With conditionals, we're checking if something is true or false. We've learned 3 JavaScript types so far in this class. What JavaScript type is represents true or false?
boolean
500
Write an infinite while loop.

while(true) { }

500

  var s = "ScriptEd "; 
  var r = "Rocks!";
  var sr = s + r;
What is stored in variable sr?
"ScriptEd Rocks"
500
Write a line of code inside this function definition so the correct value (10) gets stored in the answer variable.

function add(num1, num2) {
    var sum = num1 + num2;
    // Add a line of code here
}

var answer = add(7, 3);
return sum;
500
What will this print?

var x = 1 + "2";
console.log(x);
12
M
e
n
u