var s = "Hello";
var x = s.toLowerCase();
var l = s.length;
1. What are the types of the following:
s
x
s.toLowerCase()
s.toLowerCase
s.length
l
- Function
- Operator
- Number
- Aggregator
- Variable
- Keyword
- Operator
- Constant
var x = z[y];
4. What is y
?
- Index
- Key
- Index or key
- Array
var y = 1;
var x = [1, 2, 3];
var z = x[y];
5. What is y
?
- Index
- Key
- Index or key
- Array
var joe = {
name: 'Joe',
age: 24
};
var joesName = joe.name;
var joesAge = joe['age'];
6. What is 'age'
in the last line?
- Index
- Key
- Array
- Object
7. What are name
and age
of the object joe
?
- Index
- Key
- Object
- Property
var y = 'length';
var x = [1, 2, 3];
var z = x[y];
7. What is y
- Index
- Key
- Index or key
- Array
8. What is the element for index 1
in array x
?
9. Fill in: "The value of the (...) length
of x
is (...)"
function a() { return true; }
var a = function b() { return true; }
var c = function () { return true; }
- Declare a variable called
x
and initialize it with the string "Hello". - Declare a variable called
y
and initialize it with the propertylength
ofx
. - Declare a variable called
z
and initialize it with the result of calling the methodtoUpperCase
onx
- Declare a function called
myFunction
. This function should take two arguments, and should call the second argument with the first argument as its argument. Then, declare a variable calledf
and initialize it with an empty anonymous function, and callmyFunction
with the arguments10
andf
.
(Tip: it should look like the items in the previous question!)
var s = "HackYourFuture";
var i = s.indexOf("Your");
function sum(a, b) { return a + b; }
var s = sum(4, 5);
var r = Math.sqrt(s);
l
l = 4;
l == 4
if (l == 4) { console.log("yes"); }
E.console.log("yes");
F."yes"
G.console.log(l == 4 ? "yes" : "no")
H.function a() { return 4; }
I.var a = function () { return 4; }
var s = "Hello".toLowerCase();
var l = s.length;
function sum(a, b) {
return a + b;
}
var max = function (a, b) {
return a > b ? a : b;
}
var s1 = sum(4, 5);
var s2 = 4 + 5;
if (s2 == s1) {
console.log("same");
} else {
console.log("not same");
}
18. List all 11 statements in the code above
19. List all 28 expressions in the code above (BONUS!)