forked from ga-wdi-exercises/checkpoint-javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfundamentals.js
More file actions
33 lines (28 loc) · 1.27 KB
/
fundamentals.js
File metadata and controls
33 lines (28 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// NOTE: Make sure to use the `var` keyword for ALL variable declarations.
// #1: Create an array of strings called `foods` that contains three foods.
// Type your solution immediately below this line:
var foods = ['apples', 'pears', 'bananas']
// #2: Access the last item in the array and assign to a variable called `last`.
// Type your solution immediately below this line:
var last = foods[foods.length - 1]
// document.getElementById.foods.lastIndexOf
// #3: Create an empty array called `favoriteFoods`.
// Type your solution immediately below this line:
var favoriteFoods = []
// #4: Create a `for` loop that adds each string in `foods` to `favoriteFoods`.
// Type your solution immediately below this line:
for (let i = 0; i < foods.length; i++) {
favoriteFoods.push(foods[i])
}
// #5: Create an object literal called `instructor` that contains three key-value pairs.
// Type your solution immediately below this line:
var instructor = {
'firstName': 'Jack',
'startAge': 'forty',
'intialHeight': 'tall'
}
// #6: Add a `has-office-hours` (spelled exactly) property to `instructor` by accessing
// it (do not change the original object you typed above) and assigning it
// a boolean value.
// Type your solution immediately below this line:
instructor['has-office-hours'] = true