-
Assign the string "Jack" to a variable called
captain
-
Using the
captain
variable, use string concatenation to form the string "Oh Jack, my Jack!", assigning it to a variable namedphrase
assume to the following array:
var days = ['Thursday', 'Friday', 'Saturday', 'Sunday']
- loop through the array to print the following
0 Thursday
1 Friday
2 Saturday
3 Sunday
write a loop that print out the following:
16 bananas
14 bananas
12 bananas
10 bananas
8 bananas
6 bananas
assume the following object
var brain = {
energyLevel: 10
}
-
write code to add a
dream
property to thebrain
object with the string value'electric sheep'
-
write code to add a
dayDream
property to thebrain
object with the value{ lunch: ['burger', 'beer'] }
-
write code to add
'pudding'
to the beginning of the lunch array
assume to the following object:
var dog = {
name: 'fluffy',
age: 4,
hairColor: 'pink'
}
- research the builtin
Object.keys()
function and use it to console log all the property names as an array
- Write a function isOdd that accepts a number as a parameter and return a boolean to indicate wether the number is odd or not
examples of calling the function in the console
> isOdd(2)
< false
> isOdd(3)
< true
- Invoke the function with 6 as arguments and save it to a variable named
result
given the following array
var studentYearOfBirths = [2001, 1975, 1992, 1998, 1988, 1994]
-
write code to calculate the students average age
-
if you used a
for
loop solve this again usingforEach