1 2 3
let s = "Hello"; let x = s.toLowerCase(); let l = s.length;
1. What are the types of the following:
s
x
s.toLowerCase()
s.toLowerCase
s.length
l
let x = 5 + 6;
, what is +
?let x = 5 + 6;
, what is let
?1
let x = z[y];
4. What is y
?
1 2 3
let y = 1; let x = [1, 2, 3]; let z = x[y];
5. What is y
?
1 2 3 4 5 6
let joe = { name: 'Joe', age: 24 }; let joesName = joe.name; let joesAge = joe['age'];
6. What is 'age'
in the last line?
7. What are name
and age
of the object joe
?
1 2 3
let y = 'length'; let x = [1, 2, 3]; let z = x[y];
7. What is y
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; }
let a = function b() { return true; }
let c = function () { return true; }
first
and second
x
and initialize it with the string "Hello".y
and initialize it with the property length
of x
.z
and initialize it with the result of calling the method toUpperCase
on x
myFunction
. This function should take two arguments, and should call the second argument with the first argument as its argument. Then, declare a variable called f
and initialize it with an empty anonymous function, and call myFunction
with the arguments 10
and f
.(Tip: it should look like the items in the previous question!)
1 2 3 4 5
let s = "HackYourFuture"; let i = s.indexOf("Your"); function sum(a, b) { return a + b; } let s = sum(4, 5); let 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. let a = function () { return 4; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
let s = "Hello".toLowerCase(); let l = s.length; function sum(a, b) { return a + b; } let max = function (a, b) { return a > b ? a : b; } let s1 = sum(4, 5); let 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!)