Conditionals
The length property. For example:
var a = [1, 7];
a.length;
function someFunction (HERE) {
// code
}
HERE {
width: 40px;
}
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");
}
var num = 0;
var i = 0;
while(i < 4){
num = num + i;
i++;
}
alert(num);
function callMe(value1, value2) {
console.log("You passed in " + value1 + " and " + value2);
}
var num = Math.random();
// Add 1 to num
num++
num = num + 1
num += 1
++num
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");
}
var i = 0;
while(i < 5) {
i++;
console.log(i);
}
A) for(var i = 0; i < 5; i++) {
console.log(i);
}
B) for(var i = 0; i < 5; i++) {
console.log(i);
i++;
}
C) for(var i = 1; i < 6; i++) {
console.log(i);
}
D) for(var i = 1; i < 5; i++) {
console.log(i);
}
var school = ["Harlem", "Village", "Academy"];
// Your code here
http://jsbin.com/aLoBoGaP/1/edit?js,console
What will get printed when I hit Run?
var x = 3;
if(x === "3") {
console.log("true");
}else{
console.log("false");
}
for(first; second; third) {
// code
}
A) Gets run only once
B) Gets run before each iteration of the loop
C) Gets run after each iteration of the loop
first - A
second - B
third - C
True or False. Elements in an array must be the same type.
Reminder: The types we've learned so far are Strings, Numbers, and Booleans.
function myFunc() {
alert("hello");
}
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
*/
while(true) { }
for(; true; ) { }
function add(num1, num2) {
var sum = num1 + num2;
// Add a line of code here
}
var answer = add(7, 3);
var x = 1 + "2";
console.log(x);