-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
practice.js
149 lines (94 loc) · 4.2 KB
/
practice.js
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
//////////////////PROBLEM 1////////////////////
//Create a variable called myName that is a string data type
//Code here
//////////////////PROBLEM 2////////////////////
//Create a variable called myAge that is a number data type
//Code here
//////////////////PROBLEM 3////////////////////
//Create a variable called lovesCode that is a boolean data type
//Code here
//////////////////PROBLEM 4////////////////////
//Create a variable called greatestFear that is undefined because we fear nothing
//Code here
//////////////////PROBLEM 5////////////////////
//Create a variable called devMountainGoal that is null because we are just starting out
//Code here
//////////////////PROBLEM 6////////////////////
//Create a function declaration called greeting that
//accepts name as its only parameter.
//greeting should return the string "Hello, "
//plus the value of the name parameter.
//Code here
//////////////////PROBLEM 7////////////////////
//Write a function expression called newGreeting.
//Give it the same functionality as the function greeting in Problem 6.
//Code Here
//////////////////PROBLEM 8////////////////////
//Create an array called groceries with the values
//"apples", "milk", "eggs", "bread"
//Code Here
//////////////////PROBLEM 9////////////////////
//Create an object saved to the variable dog.
//The dog object should have the following properties:
//name (a string), color (a string), age (a number),
//and goodBoy (a boolean).
//Code Here
//...access the dog's name from the object and assign it to a
//variable called devMountainClassPet.
//Code Here
//////////////////PROBLEM 10////////////////////
//Write a function called nameCheck that takes in a name parameter.
//nameCheck should check if the name equals 'Steven'. If it does,
// return 'What is up Steven?'
//If the name parameter is Bryan, return 'Hey Bryan!'
// If the name parameter is anything else, return 'Cool name, NAMEPARAM'
// with NAMEPARAM being the name parameter being passed in (not literally NAMEPARAM)
// Code here
//////////////////PROBLEM 11////////////////////
// Create a function called add that takes in two parameters
// that will be numbers.
// The add function should return the two parameters added together
//Code Here
//Now invoke add, passing in the numbers 3 and 4
//storing the result in the variable mathSum.
//Code Here
//////////////////PROBLEM 12////////////////////
//Write a function called faveColorFinder that takes in one parameter called color
// that will be a string.
// If the passed in color equals 'red', return 'red is a great color'
// If the passed in color equals 'green', return 'green is a solid favorite color'
// If the passed in color equals 'black', return 'so trendy'
// Otherwise, you should return the string 'you need to evaluate your favorite color choice'
// Code here
//////////////////PROBLEM 13////////////////////
let duck = "cute";
function bathroom() {
let rubberDuck = "squeaky";
function bathtub() {
let sailorDuck = "nautical";
}
}
function pond() {
let realDuck = "fluffy";
}
//There are 4 variables above: duck, rubberDuck, sailorDuck and realDuck
//all within different scopes.
//Given the functions and variables above, edit the arrays
//below to contain only the appropriate variable names
//as strings.
//This array should contain the variable names (as strings) accessible in the global scope.
let globalScope = ["duck", "sailorDuck", "rubberDuck", "realDuck"];
//This array should contain the variable names (as strings) accessible in the bathroom function.
let bathroomScope = ["duck", "sailorDuck", "rubberDuck", "realDuck"];
//This array should contain the variable names (as strings) accessible in the bathtub function.
let bathtubScope = ["duck", "sailorDuck", "rubberDuck", "realDuck"];
//This array should contain the variable names (as strings) accessible in the pond function.
let pondScope = ["duck", "sailorDuck", "rubberDuck", "realDuck"];
//////////////////PROBLEM 14////////////////////
//Create a variable called age with your age assigned to you
// Code Here
// FLASH FORWARD TO NEXT YEAR
// reassign the value of age to be one greater than it was, because, we all get older
// Code Here
// Good news! We can live forever. Set your age to 999
// Code Here