You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: challenges/functions.js
+67-15Lines changed: 67 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -2,21 +2,73 @@
2
2
// Callbacks
3
3
4
4
// Step 1: Create a higher-order function that will accept 3 parameters. The first two can take any argument. The last is your callback. This function should return your callback that passed the first two parameters as its argument.
5
+
functionhighOrder(param1,param2,cb){
6
+
returncb(param1,param2);
7
+
}
8
+
// Step 2: Create several functions that you will callback with the previous higher order function.
9
+
// The first will return the sum of two numbers.
10
+
functionadd(num1,num2){
11
+
returnnum1+num2;
12
+
}
13
+
console.log(highOrder(2,13,add),"Add Function");
14
+
console.log(highOrder(43154,45345624,add));
15
+
console.log(highOrder(3,26,add));
16
+
// The second will return the product of two numbers.
// The seventh will return whether the firstString is included the secondString.
31
+
// The eigth will return whether the firstNumber is greater than the secondNumber.
32
+
// The ninth will return whether the firstNumber is less than the secondNumber.
33
+
// The tenth will return whether the firstNumber is greater than or equal to the secondNumber.
34
+
// The eleventh will return whether the firstNumber is less than or equal to the secondNumber.
35
+
// The twelvth will return whether the firstNumber is equivalent to the secondNumber.
36
+
// The thirteenth will return a string 'Hey the number is firstNumber' if firstNumber is greater than the secondNumber. If it isn't, return a string 'Hey the number is secondNumber'
37
+
5
38
6
-
/* Step 2: Create several functions that you will callback with the previous higher order function.
7
-
The first will return the sum of two numbers.
8
-
The second will return the product of two numbers.
9
-
The third will return the modulus of the two numbers.
10
-
The fourth will return the quotient of the two numbers.
11
-
The fifth will return the square root of the two numbers.
12
-
The sixth will accept a first and last name and return 'Hey, firstName lastName, youre a wicked cool dev'.
13
-
The seventh will return whether the firstString is included the secondString.
14
-
The eigth will return whether the firstNumber is greater than the secondNumber.
15
-
The ninth will return whether the firstNumber is less than the secondNumber.
16
-
The tenth will return whether the firstNumber is greater than or equal to the secondNumber.
17
-
The eleventh will return whether the firstNumber is less than or equal to the secondNumber.
18
-
The twelvth will return whether the firstNumber is equivalent to the secondNumber.
19
-
The thirteenth will return a string 'Hey the number is firstNumber' if firstNumber is greater than the secondNumber. If it isn't, return a string 'Hey the number is secondNumber'
20
-
*/
21
39
22
40
// Step 3: Check your work using console.log and invoke your higher order function.
Copy file name to clipboardExpand all lines: challenges/objects-arrays.js
+55Lines changed: 55 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -61,3 +61,58 @@ const gameCharacters = [
61
61
// For Loop
62
62
63
63
// Map or forEach or filter
64
+
65
+
66
+
67
+
// A local community center is holding a fund raising 5k fun run and has invited 50 small businesses to make a small donation on their behalf for some much needed updates to their facilities. Each business has assigned a representative to attend the event along with a small donation.
68
+
// Scroll to the bottom of the list to use some advanced array methods to help the event director gather some information from the businesses.
Copy file name to clipboardExpand all lines: challenges/prototypes.js
+233-4Lines changed: 233 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -2,12 +2,241 @@
2
2
3
3
// Task: You are to build a pentagonal pyramid that can return values for its volume as well as its surface areas. Follow the steps to achieve this.
4
4
5
-
// Step 1: Base Constructor -- You should create a constructor function names PentagonalPyramid that will accept properties for its base edge, and heights.
5
+
// Step 1: Base Constructor -- You should create a constructor function names PentagonalPyramid that will accept properties for its base, edge, and heights.
6
+
functionPentagonalPyramid(attr){
7
+
this.edge=attr.edge;
8
+
this.height=attr.height;
9
+
this.length=attr.length;
10
+
}
6
11
7
12
// Step 2: Volume Method -- You should create a prototype for PentagonalPyramid that returns the volume of a pentagonal pyramid. Curious about the formula??? Use Google (A DEVELOPERS BEST FRIEND)
// Step 3: Surface Area Method -- You should create a prototype fro PentagonalPyramid that returns the surface area of a pentagonal pyramid. Curious about the formula??? Use Google (A DEVELOPERS BEST FRIEND)
// Step 4: New Object -- You should create a new object that uses PentagonalPyramid. Give it the length, width, and height.
12
-
24
+
constpyramid=newPentagonalPyramid({
25
+
'edge': 5,
26
+
'height': 2,
27
+
'length': 4
28
+
});
13
29
// Test your volume and surfaceArea methods here using console.log
30
+
console.log(pyramid,'pyramid');
31
+
console.log(pyramid.volume());
32
+
console.log(pyramid.surfaceArea());
33
+
34
+
/*
35
+
Object oriented design is commonly used in video games. For this part of the assignment you will be implementing several constructor functions with their correct inheritance hierarchy.
36
+
In this file you will be creating three constructor functions: GameObject, CharacterStats, Humanoid.
37
+
At the bottom of this file are 3 objects that all end up inheriting from Humanoid. Use the objects at the bottom of the page to test your constructor functions.
38
+
Each constructor function has unique properties and methods that are defined in their block comments below:
39
+
*/
40
+
41
+
/*
42
+
=== GameObject ===
43
+
* createdAt
44
+
* name
45
+
* dimensions (These represent the character's size in the video game)
46
+
* destroy() // prototype method that returns: `${this.name} was removed from the game.`
47
+
*/
48
+
functionGameObject(buggy){
49
+
this.createdAt=buggy.createdAt;
50
+
this.name=buggy.name;
51
+
this.dimensions=buggy.dimensions;
52
+
}
53
+
54
+
GameObject.prototype.destroy=function(){
55
+
return`${this.name} was removed from the game.`
56
+
}
57
+
/*
58
+
=== CharacterStats ===
59
+
* healthPoints
60
+
* takeDamage() // prototype method -> returns the string '<object name> took damage.'
61
+
* should inherit destroy() from GameObject's prototype
0 commit comments